to-kana 0.6.0

Converts English phonetics to Kana, And Kana to small/half-width versions
Documentation
use crate::Result;
use crate::{has_hardened_diacritic, has_softened_diacritic};

/// Defines a type as being able to convert to half-width katakana.
///
/// # Example
///
/// ```
/// use to_kana::{ToKana, HalfWidth};
///
/// assert_eq!("ワールド", "wa-rudo".kata().half_width().unwrap());
/// ```
pub trait HalfWidth {
    fn half_width(self) -> Result;
}

impl HalfWidth for &str {
    fn half_width(self) -> Result {
        let mut s = String::new();
        for c in self.chars() {
            let has_softened_diacritic = has_softened_diacritic(c);
            let has_hardened_diacritic = has_hardened_diacritic(c);
            let c = match c {
                '' => '',
                '' => '',
                '' => '',
                '' | '' => '',
                '' => '',
                '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' | '' => 'ソ',
                '' | '' => '',
                '' | '' => '',
                '' | '' => '',
                '' => '',
                '' | '' => '',
                '' | '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' | '' | '' => '',
                '' | '' | '' => '',
                '' | '' | '' => '',
                '' | '' | '' => '',
                '' | '' | '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                '' => '',
                _ => c,
            };
            s.push(c);
            if has_softened_diacritic {
                s.push('');
            } else if has_hardened_diacritic {
                s.push('');
            }
        }
        Ok(s)
    }
}
impl HalfWidth for String {
    fn half_width(self) -> Result {
        let s: &str = &self;
        s.half_width()
    }
}
impl HalfWidth for Result {
    fn half_width(self) -> Result {
        self?.half_width()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn half_width_aiueo() {
        assert_eq!("アイウエオ", "アイウエオ".half_width().unwrap());
    }

    #[test]
    fn half_width_kakikukeko() {
        assert_eq!(
            "ガギグゲゴ",
            "ガギグゲゴ".half_width().unwrap()
        );
    }
}