Use std::fs helper function in dump-syntax example

This commit is contained in:
David Tolnay 2019-03-01 23:01:41 -08:00
parent 936a9ffafd
commit 3f4d6ef67c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -18,8 +18,7 @@
//! }
use std::env;
use std::fs::File;
use std::io::Read;
use std::fs;
use std::process;
fn main() {
@ -34,10 +33,7 @@ fn main() {
}
};
let mut file = File::open(&filename).expect("Unable to open file");
let mut src = String::new();
file.read_to_string(&mut src).expect("Unable to read file");
let src = fs::read_to_string(filename).expect("Unable to read file");
let syntax = syn::parse_file(&src).expect("Unable to parse file");
println!("{:#?}", syntax);