summaryrefslogtreecommitdiffstats
path: root/vendor/bstr-0.2.17/examples/words-std.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bstr-0.2.17/examples/words-std.rs')
-rw-r--r--vendor/bstr-0.2.17/examples/words-std.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/bstr-0.2.17/examples/words-std.rs b/vendor/bstr-0.2.17/examples/words-std.rs
new file mode 100644
index 000000000..aeeeb26ff
--- /dev/null
+++ b/vendor/bstr-0.2.17/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(())
+}