feat(examples): add iter example
This commit is contained in:
parent
d49cd135d8
commit
c86fef91a0
2 changed files with 22 additions and 3 deletions
19
examples/iter.rs
Normal file
19
examples/iter.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use orgize::Org;
|
||||
use std::env::args;
|
||||
use std::fs;
|
||||
use std::io::Result;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args: Vec<_> = args().collect();
|
||||
|
||||
if args.len() < 2 {
|
||||
eprintln!("Usage: {} <org-file>", args[0]);
|
||||
} else {
|
||||
let contents = String::from_utf8(fs::read(&args[1])?).unwrap();
|
||||
|
||||
for event in Org::parse(&contents).iter() {
|
||||
println!("{:?}", event);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue