Crate salph

source ·
Expand description

salph is a library that allows you to transform &strs to Vecs of words from spelling alphabets.

Usage:

use salph::{SpellingAlphabet, Alphabet, Spelling};
use std::str::FromStr;

// Load a spelling alphabet using the Alphabet enum
let spelling_alphabet = SpellingAlphabet::load(Alphabet::nato).unwrap();
let word_list = spelling_alphabet.str_to_spellings("abc123");
assert_eq!(word_list, [
    Spelling { spelling: "Alpha".to_string(), is_number: false },
    Spelling { spelling: "Bravo".to_string(), is_number: false },
    Spelling { spelling: "Charlie".to_string(), is_number: false },
    Spelling { spelling: "one".to_string(), is_number: true },
    Spelling { spelling: "two".to_string(), is_number: true },
    Spelling { spelling: "three".to_string(), is_number: true },
]);

// Load a spelling alphabet using an &str
let spelling_alphabet = SpellingAlphabet::from_str("nato").unwrap();
let word_list = spelling_alphabet.str_to_spellings("abc")
        .iter()
        .map(|x| x.spelling.clone())
        .collect::<Vec<_>>();
assert_eq!(word_list, ["Alpha", "Bravo", "Charlie"]);

Supported alphabets can be found in the Alphabet struct

Structs

Enums