morse-lib

Define a function

1
2
3
4
5
6
7
8
use morse_lib::Morse;

pub fn print_morse(message: &str) {
    let morse = Morse::from_text(message)
        .expect("expected morse decoded")
        .to_string();
    println!("{morse:?}");
}

Use the function

1
print_morse("HELLO");
(stdout)
". . . .   .   . ⚊ . .   . ⚊ . .   ⚊ ⚊ ⚊"