[−][src]Struct ispell::SpellChecker
Spell Checker
Checks the spelling of a line.
Example
use ispell::SpellLauncher; let mut checker = SpellLauncher::new().launch().unwrap(); let errors = checker.check("This should not contain any error").unwrap(); assert!(errors.is_empty());
Implementations
impl SpellChecker
[src]
pub fn add_word_to_dictionary(&mut self, word: &str) -> Result<()>
[src]
Adds a word to your personal dictionary
The word will be saved to your words file (e.g. ~/.ispell_LANG,
~/.hunspell_LANG, or
~/.aspell.LANG.pws), so it will be memorized next time you use i/a/hun/spell. If you only want to add the word to this current session, use
add_word`.
Returns
An error if connection to ispell failed, or word
contains multiple words (i.e., spaces).
Note that a successful return of this method doesn't mean that the word was successfully added, as it is possible that it contains invalid character and ispell will reject it.
Examples
Adding a valid word
use ispell::SpellLauncher; fn main() { let mut checker = SpellLauncher::new() .launch() .unwrap(); // "rustacean" is not a valid word... // (unless you already ran this code example) let errors = checker.check("rustacean").unwrap(); assert_eq!(errors.len(), 1); // let's add it to our personal dictionary checker.add_word_to_dictionary("rustacean").unwrap(); // now it is a valid word let errors = checker.check("rustacean").unwrap(); assert!(errors.is_empty()); }
Invalid word: contains spaces
let mut checker = SpellLauncher::new() .launch() .unwrap(); let res = checker.add_word_to_dictionary("multiple words"); assert!(res.is_err());
pub fn add_word(&mut self, word: &str) -> Result<()>
[src]
Add a word to current session.
Similar to add_word_to_dictionary
, except word
won't be memorized the next time you use i/a/hun/spell.
use ispell::SpellLauncher; fn main() { let mut checker = SpellLauncher::new() .launch() .unwrap(); // "rustaholic" is not a valid word... // (even if you already ran this code example) let errors = checker.check("rustaholic").unwrap(); assert_eq!(errors.len(), 1); // let's add it to this session checker.add_word("rustaholic").unwrap(); // now it is a valid word let errors = checker.check("rustaholic").unwrap(); assert!(errors.is_empty()); }
pub fn check(&mut self, text: &str) -> Result<Vec<IspellError>>
[src]
Checks the spelling of a line.
This method only returns the errors that ispell detects. Since the position returned in those errors is the number of characters since the beginning of the line, this method needs to be called line by line and not on a full document.
pub fn check_raw(&mut self, text: &str) -> Result<Vec<IspellResult>>
[src]
Checks the spelling of a string
This method returns a vector of all ispell
answers, even when
there is no errors. Usually, the check
method, which only returns
errors, will be more useful.
Trait Implementations
impl Drop for SpellChecker
[src]
Auto Trait Implementations
impl !RefUnwindSafe for SpellChecker
impl Send for SpellChecker
impl !Sync for SpellChecker
impl Unpin for SpellChecker
impl !UnwindSafe for SpellChecker
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,