Struct cmudict_fast::Cmudict[][src]

pub struct Cmudict { /* fields omitted */ }

A dictionary containing words & their pronunciations

Implementations

impl Cmudict[src]

pub fn new<P: AsRef<Path>>(dict: P) -> Result<Cmudict>[src]

Takes a path to a cmudict file and tries to construct a Cmudict struct

Example

use cmudict_fast as cmudict;
use cmudict::Cmudict;

let dict = Cmudict::new("./resources/cmudict.dict")?;

pub fn get(&self, s: &str) -> Option<&[Rule]>[src]

Look for a word in the dictionary, and retrieve it’s pronunciation

Example

use cmudict_fast as cmudict;
use cmudict::{Cmudict, Symbol, Stress};

let dict = Cmudict::new("./resources/cmudict.dict")?;
let rust = dict.get("rust");

assert!(rust.is_some());
assert_eq!(
    rust.unwrap().first().unwrap().pronunciation(),
    &[Symbol::R,
      Symbol::AH(Stress::Primary),
      Symbol::S,
      Symbol::T]
);

Trait Implementations

impl Debug for Cmudict[src]

impl FromStr for Cmudict[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl RefUnwindSafe for Cmudict

impl Send for Cmudict

impl Sync for Cmudict

impl Unpin for Cmudict

impl UnwindSafe for Cmudict

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.