Replaced try!() macros with new ? operator.
This commit is contained in:
parent
f1e558de05
commit
746b3b0c1f
|
@ -25,7 +25,7 @@ impl<'a> DataTree<'a> {
|
|||
let mut items = Vec::new();
|
||||
let mut remaining_text = (0, source_text);
|
||||
|
||||
while let Some((item, text)) = try!(parse_node(remaining_text)) {
|
||||
while let Some((item, text)) = parse_node(remaining_text)? {
|
||||
remaining_text = text;
|
||||
items.push(item);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ fn parse_node<'a>(source_text: (usize, &'a str)) -> ParseResult<'a> {
|
|||
if let (Token::OpenInner, text3) = next_token(text2) {
|
||||
let mut children = Vec::new();
|
||||
let mut text_remaining = text3;
|
||||
while let Some((node, text4)) = try!(parse_node(text_remaining)) {
|
||||
while let Some((node, text4)) = parse_node(text_remaining)? {
|
||||
text_remaining = text4;
|
||||
children.push(node);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ fn parse_node<'a>(source_text: (usize, &'a str)) -> ParseResult<'a> {
|
|||
(Token::OpenInner, text2) => {
|
||||
let mut children = Vec::new();
|
||||
let mut text_remaining = text2;
|
||||
while let Some((node, text3)) = try!(parse_node(text_remaining)) {
|
||||
while let Some((node, text3)) = parse_node(text_remaining)? {
|
||||
text_remaining = text3;
|
||||
children.push(node);
|
||||
}
|
||||
|
|
|
@ -49,23 +49,23 @@ pub fn parse_scene(tree: &DataTree) -> Result<Renderer, PsyParseError> {
|
|||
}
|
||||
|
||||
// Parse output info
|
||||
let output_info = try!(parse_output_info(tree.iter_children_with_type("Output")
|
||||
let output_info = parse_output_info(tree.iter_children_with_type("Output")
|
||||
.nth(0)
|
||||
.unwrap()));
|
||||
.unwrap())?;
|
||||
|
||||
// Parse render settings
|
||||
let render_settings = try!(parse_render_settings(tree.iter_children_with_type("RenderSettings")
|
||||
let render_settings = parse_render_settings(tree.iter_children_with_type("RenderSettings")
|
||||
.nth(0)
|
||||
.unwrap()));
|
||||
.unwrap())?;
|
||||
|
||||
// Parse camera
|
||||
let camera = try!(parse_camera(tree.iter_children_with_type("Camera").nth(0).unwrap()));
|
||||
let camera = parse_camera(tree.iter_children_with_type("Camera").nth(0).unwrap())?;
|
||||
|
||||
// Parse world
|
||||
let world = try!(parse_world(tree.iter_children_with_type("World").nth(0).unwrap()));
|
||||
let world = parse_world(tree.iter_children_with_type("World").nth(0).unwrap())?;
|
||||
|
||||
// Parse root scene assembly
|
||||
let assembly = try!(parse_assembly(tree.iter_children_with_type("Assembly").nth(0).unwrap()));
|
||||
let assembly = parse_assembly(tree.iter_children_with_type("Assembly").nth(0).unwrap())?;
|
||||
|
||||
// Put scene together
|
||||
let scene_name = if let &DataTree::Internal { ident, .. } = tree {
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
|
|||
// Sub-Assembly
|
||||
"Assembly" => {
|
||||
if let &DataTree::Internal { ident: Some(ident), .. } = child {
|
||||
builder.add_assembly(ident, try!(parse_assembly(&child)));
|
||||
builder.add_assembly(ident, parse_assembly(&child)?);
|
||||
} else {
|
||||
// TODO: error condition of some kind, because no ident
|
||||
panic!();
|
||||
|
@ -46,7 +46,7 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
|
|||
// Get xforms
|
||||
let mut xforms = Vec::new();
|
||||
for (_, contents) in child.iter_leaf_children_with_type("Transform") {
|
||||
xforms.push(try!(parse_matrix(contents)));
|
||||
xforms.push(parse_matrix(contents)?);
|
||||
}
|
||||
|
||||
// Add instance
|
||||
|
@ -62,10 +62,8 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
|
|||
// MeshSurface
|
||||
"MeshSurface" => {
|
||||
if let &DataTree::Internal { ident: Some(ident), .. } = child {
|
||||
builder.add_object(
|
||||
ident,
|
||||
Object::Surface(Box::new(try!(parse_mesh_surface(&child))))
|
||||
);
|
||||
builder.add_object(ident,
|
||||
Object::Surface(Box::new(parse_mesh_surface(&child)?)));
|
||||
} else {
|
||||
// TODO: error condition of some kind, because no ident
|
||||
panic!();
|
||||
|
@ -76,7 +74,7 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
|
|||
"SphereLight" => {
|
||||
if let &DataTree::Internal { ident: Some(ident), .. } = child {
|
||||
builder.add_object(ident,
|
||||
Object::Light(Box::new(try!(parse_sphere_light(&child)))));
|
||||
Object::Light(Box::new(parse_sphere_light(&child)?)));
|
||||
} else {
|
||||
// TODO: error condition of some kind, because no ident
|
||||
panic!();
|
||||
|
@ -87,9 +85,7 @@ pub fn parse_assembly(tree: &DataTree) -> Result<Assembly, PsyParseError> {
|
|||
"RectangleLight" => {
|
||||
if let &DataTree::Internal { ident: Some(ident), .. } = child {
|
||||
builder.add_object(ident,
|
||||
Object::Light(Box::new(
|
||||
try!(parse_rectangle_light(&child))
|
||||
)));
|
||||
Object::Light(Box::new(parse_rectangle_light(&child)?)));
|
||||
} else {
|
||||
// TODO: error condition of some kind, because no ident
|
||||
panic!();
|
||||
|
|
Loading…
Reference in New Issue
Block a user