Trait Wordlist

Source
pub trait Wordlist {
    // Required method
    fn get_all() -> &'static [&'static str];

    // Provided methods
    fn get(index: usize) -> Result<&'static str, WordlistError> { ... }
    fn get_index(word: &str) -> Result<usize, WordlistError> { ... }
}
Expand description

The Wordlist trait that every language’s wordlist must implement.

Required Methods§

Source

fn get_all() -> &'static [&'static str]

Returns the word list as a string.

Implementor’s note: this MUST be sorted

Provided Methods§

Source

fn get(index: usize) -> Result<&'static str, WordlistError>

Returns the word of a given index from the word list.

Source

fn get_index(word: &str) -> Result<usize, WordlistError>

Returns the index of a given word from the word list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§