#text #allocation #words #punctuation #entries #discarding

extract-words

Extracts words from text without allocation

2 unstable releases

0.2.0 Feb 16, 2024
0.1.0 Feb 15, 2024

#528 in Text processing

26 downloads per month

MIT license

8KB
110 lines

License Crates.io Docs.rs

extract-words

Extracts words from text without allocation

Examples

Iteration through words, discarding punctuation

let mut words = extract_words("¿Cómo estás?");
assert_eq!(words.next().unwrap(), "Cómo");
assert_eq!(words.next().unwrap(), "estás");
assert!(words.next().is_none());

Iteration through all entries

let mut entries = Entries::new("Bien :)");
assert_eq!(entries.next().unwrap(), Entry::Word("Bien"));
assert_eq!(entries.next().unwrap(), Entry::Other(" :)"));
assert!(entries.next().is_none());

Contributing

We appreciate all kinds of contributions, thank you!

Note on README

Most of the readme is automatically copied from the crate documentation by cargo-sync-readme. This way the readme is always in sync with the docs and examples are tested.

So if you find a part of the readme you'd like to change between <!-- cargo-sync-readme start --> and <!-- cargo-sync-readme end --> markers, don't edit README.md directly, but rather change the documentation on top of src/lib.rs and then synchronize the readme with:

cargo sync-readme

(make sure the cargo command is installed):

cargo install cargo-sync-readme

If you have rusty-hook installed the changes will apply automatically on commit.

License

This project is licensed under the MIT license.

No runtime deps