[−][src]Function josa::select
pub fn select(noun: &str, josa: Josa) -> Result<&str, JosaError>
Select appropriate josa for the noun.
It is useful when you are trying to append a josa to formatted text such as <span>고양이</span>
.
If you try to append a josa to <span>고양이</span>
, it results in JosaError
because of the last character >
.
With this method, you can first get an appropriate josa, and then format the text with the that:
use josa::select; use josa::Josa::IGa; let cat = "고양이"; let josa = select(cat, IGa)?; let cat = format!(r#"<span class="bold">{}</span>{}"#, cat, josa); assert_eq!(cat, r#"<span class="bold">고양이</span>가"#);
Errors
If the noun is an empty String or last character is not a Haugul Syllable, it returns JosaError
Example
use josa::select; use josa::Josa::IGa; assert_eq!(select("고양이", IGa)?, "가");
use josa::select; use josa::Josa::EunNeun; assert_eq!(select("사냥꾼", EunNeun)?, "은");