Skip to content

Commit 39ca851

Browse files
committed
Add an example for Dictionary::check
1 parent c73ac1a commit 39ca851

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ impl<S: BuildHasher> Dictionary<S> {
9292
/// patterns" which Spellbook respects though. For example `check("light-weight-like")`
9393
/// returns `true` for the `en_US` dictionary because the break patterns allow splitting into
9494
/// the words "light", "weight" and "like".
95+
///
96+
/// # Example
97+
///
98+
/// ```
99+
/// let dic = std::fs::read_to_string("./vendor/en_US/en_US.dic").unwrap();
100+
/// let aff = std::fs::read_to_string("./vendor/en_US/en_US.aff").unwrap();
101+
/// let dict = spellbook::Dictionary::new(&dic, &aff).unwrap();
102+
///
103+
/// assert!(dict.check("optimize"));
104+
/// assert!(!dict.check("optimise")); // allowed by en_GB but not en_US.
105+
/// ```
95106
pub fn check(&self, word: &str) -> bool {
96107
Checker::new(self).check(word)
97108
}

0 commit comments

Comments
 (0)