#[cfg(feature = "english")]
pub mod english;
#[cfg(feature = "english")]
pub use self::english::English;
#[cfg(feature = "chinese-simplified")]
pub mod chinese_simplified;
#[cfg(feature = "chinese-simplified")]
pub use self::chinese_simplified::ChineseSimplified;
#[cfg(feature = "chinese-traditional")]
pub mod chinese_traditional;
#[cfg(feature = "chinese-traditional")]
pub use super::chinese_traditional::ChineseTraditional;
#[cfg(feature = "czech")]
pub mod czech;
#[cfg(feature = "czech")]
pub use super::czech::Czech;
#[cfg(feature = "french")]
pub mod french;
#[cfg(feature = "french")]
pub use super::french::French;
#[cfg(feature = "italian")]
pub mod italian;
#[cfg(feature = "italian")]
pub use super::italian::Italian;
#[cfg(feature = "japanese")]
pub mod japanese;
#[cfg(feature = "japanese")]
pub use super::japanese::Japanese;
#[cfg(feature = "korean")]
pub mod korean;
#[cfg(feature = "korean")]
pub use super::korean::Korean;
#[cfg(feature = "portuguese")]
pub mod portuguese;
#[cfg(feature = "portuguese")]
pub use super::portuguese::Portuguese;
#[cfg(feature = "spanish")]
pub mod spanish;
#[cfg(feature = "spanish")]
pub use super::spanish::Spanish;
use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum WordlistError {
#[error("the index `{0}` is invalid")]
InvalidIndex(usize),
#[error("the word `{0}` is invalid")]
InvalidWord(String),
}
pub trait Wordlist {
fn get_all() -> &'static [&'static str];
fn get(index: usize) -> Result<&'static str, WordlistError> {
Self::get_all()
.get(index)
.map(std::ops::Deref::deref)
.ok_or(crate::WordlistError::InvalidIndex(index))
}
fn get_index(word: &str) -> Result<usize, WordlistError> {
Self::get_all()
.iter()
.position(|&x| x == word)
.ok_or(crate::WordlistError::InvalidWord(word.to_string()))
}
}