- let mut toml = String::new();
- t!(f.read_to_string(&mut toml));
- let mut p = Parser::new(&toml);
- let table = match p.parse() {
- Some(table) => table,
- None => {
- println!("failed to parse TOML configuration '{}':", file.to_str().unwrap());
- for err in p.errors.iter() {
- let (loline, locol) = p.to_linecol(err.lo);
- let (hiline, hicol) = p.to_linecol(err.hi);
- println!("{}:{}-{}:{}: {}", loline, locol, hiline,
- hicol, err.desc);
- }
- process::exit(2);
- }
- };
- let mut d = Decoder::new(Value::Table(table));
- match Decodable::decode(&mut d) {
- Ok(cfg) => cfg,
- Err(e) => {
- println!("failed to decode TOML: {}", e);
+ let mut contents = String::new();
+ t!(f.read_to_string(&mut contents));
+ match toml::from_str(&contents) {
+ Ok(table) => table,
+ Err(err) => {
+ println!("failed to parse TOML configuration '{}': {}",
+ file.display(), err);