Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API suggestion: traits implemented for &str and char for more ergonomic operations #7

Closed
TianyiShi2001 opened this issue Jun 18, 2021 · 2 comments

Comments

@TianyiShi2001
Copy link
Contributor

I was reinventing the wheel yesterday (https://github.com/TianyiShi2001/romkan ) before I realize there is already a kana-romaji conversion library here, and this library proved to be faster than mine. However, I think my approach, which is to implement a Trait directly on &str which allows conversion between kana and romaji, is more ergonomic and idiomatic, since it is similar to the std::str's .to_lowercase and .to_uppercase

use romkan::Romkan;

fn main() {
    println!("{}", "kyouhatennkigaiidesune".to_hiragana());
    println!("{}", "きょうはてんきがいいですね".to_romaji());
}

// compared to

use wana_kana::{to_hiragana::to_hiragana, to_romaji::to_romaji};

fn main() {
    println!("{}", to_hiragana("kyouhatennkigaiidesune"));
    println!("{}", to_romaji("きょうはてんきがいいですね"));
}

Similarly, methods such as .is_hiragana implemented for char will be more ergonomic given there exists .is_alphabetic, .is_digit etc. on char in std.

Would you like these kinds of traits to be added to your crate?

@PSeitz
Copy link
Owner

PSeitz commented Jun 18, 2021

Thanks for the suggestion, I think this API would be much better, than the existing one.

@TianyiShi2001
Copy link
Contributor Author

Great, I will start working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants