summaryrefslogtreecommitdiffstats
path: root/vendor/bstr/examples/words-std.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bstr/examples/words-std.rs')
-rw-r--r--vendor/bstr/examples/words-std.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/bstr/examples/words-std.rs b/vendor/bstr/examples/words-std.rs
new file mode 100644
index 0000000..aeeeb26
--- /dev/null
+++ b/vendor/bstr/examples/words-std.rs
@@ -0,0 +1,18 @@
+use std::error::Error;
+use std::io::{self, BufRead};
+
+use unicode_segmentation::UnicodeSegmentation;
+
+fn main() -> Result<(), Box<dyn Error>> {
+ let stdin = io::stdin();
+ let mut stdin = stdin.lock();
+
+ let mut words = 0;
+ let mut line = String::new();
+ while stdin.read_line(&mut line)? > 0 {
+ words += line.unicode_words().count();
+ line.clear();
+ }
+ println!("{}", words);
+ Ok(())
+}