Expand description
§reading-time — estimate how long a text takes to read
Count the words in a text and estimate the reading time, with sensible handling of CJK
characters (each counts as a word, and trailing punctuation is absorbed). A faithful Rust
port of the widely-used reading-time npm
package.
use reading_time::reading_time;
let result = reading_time("Hello world, this is a test.");
assert_eq!(result.words, 6);
assert_eq!(result.text, "1 min read");Use reading_time_with to set the words-per-minute rate (default 200):
use reading_time::reading_time_with;
assert_eq!(reading_time_with(&"word ".repeat(400), 200).minutes, 2.0);Zero dependencies. (Uses std for floating-point rounding.)
Structs§
- Reading
Time - The result of a reading-time estimate.
Functions§
- reading_
time - Estimate the reading time of
textat 200 words per minute. - reading_
time_ with - Estimate the reading time of
textatwords_per_minute(a value of0falls back to the default of 200, matching the reference).