{"action":"opened","issue":{"url":"https://api.github.com/repos/PistonDevelopers/meta/issues/295","labels_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/295/comments","events_url":"https://api.github.com/repos/PistonDevelopers/meta/issues/295/events","html_url":"https://github.com/PistonDevelopers/meta/issues/295","id":114079992,"number":295,"title":"Add a simpler function for parsing returning a `String` error","user":{"login":"bvssvni","id":1743862,"avatar_url":"https://avatars.githubusercontent.com/u/1743862?v=3","gravatar_id":"","url":"https://api.github.com/users/bvssvni","html_url":"https://github.com/bvssvni","followers_url":"https://api.github.com/users/bvssvni/followers","following_url":"https://api.github.com/users/bvssvni/following{/other_user}","gists_url":"https://api.github.com/users/bvssvni/gists{/gist_id}","starred_url":"https://api.github.com/users/bvssvni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvssvni/subscriptions","organizations_url":"https://api.github.com/users/bvssvni/orgs","repos_url":"https://api.github.com/users/bvssvni/repos","events_url":"https://api.github.com/users/bvssvni/events{/privacy}","received_events_url":"https://api.github.com/users/bvssvni/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PistonDevelopers/meta/labels/discussion","name":"discussion","color":"bfe5bf"},{"url":"https://api.github.com/repos/PistonDevelopers/meta/labels/draft","name":"draft","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-29T15:48:20Z","updated_at":"2015-10-29T15:48:20Z","closed_at":null,"body":"Alternative to https://github.com/PistonDevelopers/meta/issues/272\r\n\r\nThe `parse` function has access to the source, so it could be `parse_errstr` or something similar.\r\n\r\nExample from Eco:\r\n\r\n```Rust\r\nmatch parse(&cargo_toml_rules, &config, &mut cargo_toml_data) {\r\n    Ok(val) => val,\r\n    Err(range_err) => {\r\n        let mut w: Vec<u8> = vec![];\r\n        ParseErrorHandler::new(&config).write(&mut w, range_err).unwrap();\r\n        return Err(format!(\"{}: Syntax error in Cargo.toml for url `{}`\\n{}\",\r\n            &extract.package, &extract.url, &String::from_utf8(w).unwrap()));\r\n    }\r\n};\r\n```\r\n\r\nbecomes:\r\n\r\n```Rust\r\ntry!(parse_errstr(&cargo_toml_rules, &config, &mut cargo_toml_data)\r\n        .map_err(|err| format!(\"{}: Syntax error in Cargo.toml for url `{}`\\n{}\",\r\n            &extract.package, &extract.url, &err)));\r\n```"}}