Dictionary

Struct Dictionary 

Source
pub struct Dictionary { /* private fields */ }

Implementations§

Source§

impl Dictionary

Source

pub fn new<P: Into<PathBuf>>(path: P) -> Dictionary

Create a new Dictionary instance. But not read the file data. Use the read_data method to read data file the input file.

Source§

impl Dictionary

Source

pub fn count(&self) -> usize

Get the count of words.

Source

pub fn get_all_right(&self, index: usize) -> Option<&[String]>

Get the all right words.

Source

pub fn get_all_right_to_string(&self, index: usize) -> Option<String>

Get the all right words.

Source

pub fn get_right(&self, index: usize) -> Option<&str>

Get the last right word at a specific index.

Source

pub fn get_left(&self, index: usize) -> Option<&str>

Get the left word at a specific index

Source§

impl Dictionary

Source

pub fn find_left_strictly<S: AsRef<str>>( &self, s: S, start_index: usize, ) -> Option<usize>

Find a word by a keyword.

Source

pub fn find_left<S: AsRef<str>>( &self, s: S, start_index: usize, ) -> Option<usize>

Find a word by a keyword.

Source

pub fn find_right_strictly<S: AsRef<str>>( &self, s: S, start_index: usize, ) -> Option<usize>

Find a word by a keyword.

Source

pub fn find_right<S: AsRef<str>>( &self, s: S, start_index: usize, ) -> Option<usize>

Find a word by a keyword.

Source§

impl Dictionary

Source

pub fn read_data(&mut self) -> Result<(), ReadError>

Read the dictionary from the dictionary file.

Source§

impl Dictionary

Source

pub fn write_data(&mut self) -> Result<(), WriteError>

Write this dictionary to its dictionary file.

Source

pub fn delete(&mut self, index: usize) -> Result<bool, WriteError>

Delete a word.

Source

pub fn add_edit<L: AsRef<str>, R: AsRef<str>>( &mut self, left: L, right: R, ) -> Result<bool, WriteError>

Add or edit a word. If the left word exists, then update it, and return Ok(false).

Trait Implementations§

Source§

impl Debug for Dictionary

Source§

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

Formats the value using the given formatter. 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, 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.