mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Use std::fs helper function in dump-syntax example
This commit is contained in:
parent
936a9ffafd
commit
3f4d6ef67c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user