pub struct Lexicon {
pub terms: Vec<Term>,
}
Expand description
Struct representing the content of a lexicon.
Fields§
§terms: Vec<Term>
All the terms extracted from the lexicon.
let lexicon = lexicon::Lexicon::get();
assert_eq!(lexicon.terms.len() > 10, true);
Implementations§
Source§impl Lexicon
impl Lexicon
Sourcepub fn get_term(&self, name: String) -> Option<&Term>
pub fn get_term(&self, name: String) -> Option<&Term>
Look for a term by its name.
§Examples
§With known term name
let lexicon = lexicon::Lexicon::get();
let glider = lexicon.get_term("glider".to_string()).unwrap();
assert_eq!(glider.name, "glider".to_string());
§With unknown term name
let lexicon = lexicon::Lexicon::get();
let glider = lexicon.get_term("unknwon pattern".to_string());
assert_eq!(glider.is_none(), true);
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Lexicon
impl<'de> Deserialize<'de> for Lexicon
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Lexicon
impl RefUnwindSafe for Lexicon
impl Send for Lexicon
impl Sync for Lexicon
impl Unpin for Lexicon
impl UnwindSafe for Lexicon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more