1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub extern crate regex;
pub extern crate rand;

/// Macro that UwUizes a String
///
/// # Examples
///
/// ```
/// use uwuizer::*;
/// let uwuized = uwuize!("Example text");
/// ```
#[macro_export]
macro_rules! uwuize {
    ($x:expr) => {{
        use regex::Regex;
        use std::str::FromStr;
        use rand::seq::IteratorRandom;

        let mut uwuized: String = String::from_str($x).unwrap();
        let mut rng = rand::thread_rng();
        [
            ("(?:r|l)", "w"),
            ("(?:R|L)", "W"),
            ("n([aeiou])", "ny$1"),
            ("N([aeiou])", "Ny$1"),
            ("N([AEIOU])", "NY$1"),
            ("ove", "uv"),
            ("!+", ["(・`ω´・)", "Uwu", "uwu", "oωo", "òωó", "°ω°", "UwU", ">w<", "^w^"].iter().choose(&mut rng).unwrap()),
        ].iter().for_each(|(f, t)| {
            let re = Regex::new(f).unwrap();
            uwuized = re.replace_all(&uwuized, *t).to_string();
        });
        uwuized
    }}
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn uwu() {
        let uwuized = uwuize!("malfunction me mom.. t-till i break~~");
        println!("\t{}", uwuized);
    }
    #[test]
    fn all_match_uwu() {
        let uwuized = uwuize!("r l R L na Na NA ove !!");
        println!("\t{}", uwuized);
    }
}