Idiomatic josa selector.
Josa is a [Rust] library to select appropriate josas for korean language.
push_josa
methodJosa is an [extension trait] implemented for [String
] type.
Its API works just like [push_str
] method on [String
].
```rust use josa::JosaExt; use josa::Josa::{EunNeun, IGa};
let mut user = "유진".toowned(); let mut mackerel = "고등어".toowned();
user.pushjosa(EunNeun); mackerel.pushjosa(IGa);
let sentence = format!("{} {} 먹고싶다", user, mackerel);
assert_eq!(sentence, "유진은 고등어가 먹고싶다"); ```
:warning: Like [
push_str
] does,push_josa
expects [String
], not [str
], as its argument.
+
, +=
operatorYou can use +
, +=
operator to append josa.
```rust use josa::Josa::{EunNeun, IGa};
let user = "유진".toowned(); let mackerel = "고등어".toowned();
let sentence = format!("{} {} 먹고싶다", user + EunNeun, mackerel + IGa);
assert_eq!(sentence, "유진은 고등어가 먹고싶다"); ```
select
methodIn case you want to append a josa to formatted text such as <span>고양이</span>
,
you can use select
method.
```rust use josa::select; use josa::Josa::IGa;
let cat = "고양이"; let josa = select(cat, IGa).unwrap();
let cat = format!(r#"{}{}"#, cat, josa);
assert_eq!(cat, r#"고양이가"#); ```
Add josa
as a dependency in your Cargo.toml
.
toml
[dependencies]
josa = "0.1.2"
Now you can use josa crate.
rust
use josa::*;
// Use here..
See docs.rs
select
macroAs soon as hygiene 2.0 (#54727) arrives stable, we will add support for following macro:
rust
select!("{}{은} {}{가} 먹고싶다", user, mackerel);
which is terser than current syntax:
As soon as non-ASCII identifiers (#55467) arrives stable, we will change the names of josas to Hangul:
rust
format!("{} {} 먹고싶다", user + 은는, mackerel + 이가);
Distributed under the MIT license.