Skip to main content

WordList

Struct WordList 

Source
pub struct WordList { /* private fields */ }
Expand description

A list of words, with optional additional metadata.

Implementations§

Source§

impl WordList

Source

pub fn load( path: impl AsRef<Path>, metadata_path: impl AsRef<Path>, ) -> Result<WordList, WordListError>

Load a word list from a file.

The file is expected to contain one word per line. The word list may also be accompanied by a metadata TOML file. A fully specified metadata file may look like this:

name = "diffenator_latin"
script = "Latn"
Source

pub fn load_without_metadata( path: impl AsRef<Path>, ) -> Result<WordList, WordListError>

Load a word list from a file.

The file is expected to contain one word per line. Always prefer WordList::load if metadata is available.

Source

pub fn define( name: impl Into<String>, words: impl IntoIterator<Item = impl Into<String>>, ) -> WordList

Create a new word list from an iterable.

Metadata is unspecified.

Source

pub fn name(&self) -> &str

Get the name of the word list.

Source

pub fn script(&self) -> Option<&str>

Get the script of the word list, if known.

The script is expected to be a ISO 15924 four-letter capitalised code, but this is only guaranteed for built-in word lists.

Source

pub fn language(&self) -> Option<&str>

Get the language of the word list, if known.

The language is expected to be a ISO 639-1 two-letter code, but this is only guaranteed for built-in word lists.

Source

pub fn iter(&self) -> WordListIter<'_>

Iterate through the word list.

Source

pub fn len(&self) -> usize

Get how many words there are in the word list.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no words in the word list.

Source§

impl WordList

Source

pub fn par_iter(&self) -> ParWordListIter<'_>

Iterate through the word list in parallel with rayon.

Trait Implementations§

Source§

impl Debug for WordList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Index<usize> for WordList

Source§

type Output = str

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &<WordList as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> IntoParallelIterator for &'a WordList

Source§

type Item = &'a str

The type of item that the parallel iterator will produce.
Source§

type Iter = ParWordListIter<'a>

The parallel iterator type that will be created.
Source§

fn into_par_iter(self) -> <&'a WordList as IntoParallelIterator>::Iter

Converts self into a parallel iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

Source§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
Source§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
Source§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.