From 14d055dcc41044061357f206fe4ed71ce61fffce Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 25 Dec 2016 22:16:46 -0800 Subject: rustfmt --- src/transpile_js.rs | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/transpile_js.rs') diff --git a/src/transpile_js.rs b/src/transpile_js.rs index d4ed5f7..1fa6075 100644 --- a/src/transpile_js.rs +++ b/src/transpile_js.rs @@ -13,33 +13,30 @@ impl TranspileJS for ModelicaModel { let mut constants = vec![]; for (c, e) in self.get_constant_vars() { if let Some(v) = e { - constants.push(format!("var {} = {};", - c, try!(v.repr_js()))); + constants.push(format!("var {} = {};", c, try!(v.repr_js()))); } } let mut binds = vec![]; let mut outputs = vec![]; for eq in self.equations.iter() { if let Expr::Ident(ref symb) = eq.lhs { - binds.push(format!("var {} = {};", - symb, - try!(eq.rhs.repr_js()))); + binds.push(format!("var {} = {};", symb, try!(eq.rhs.repr_js()))); outputs.push(symb.to_string()); } else { - return Err("Expected an identifier on LHS (in this partial implementation)".to_string()) + return Err("Expected an identifier on LHS (in this partial implementation)" + .to_string()); } } - Ok(format!( - r#"function {slug}({args}) {{ + Ok(format!(r#"function {slug}({args}) {{ {constants} {binds} return [{outputs}]; }}"#, - slug = "f", - args = self.get_free_vars().join(", "), - constants = constants.join("\n "), - binds = binds.join("\n "), - outputs = outputs.join(", "))) + slug = "f", + args = self.get_free_vars().join(", "), + constants = constants.join("\n "), + binds = binds.join("\n "), + outputs = outputs.join(", "))) } } @@ -56,11 +53,9 @@ impl TranspileJS for Expr { Der(ref e) => Ok(format!("der({})", try!(e.repr_js()))), Sign(ref e) => Ok(format!("sign({})", try!(e.repr_js()))), MathUnaryExpr(func, ref e) => Ok(format!("{:?}({})", func, try!(e.repr_js()))), - BinExpr(op, ref l, ref r) => - Ok(format!("({} {:?} {})", - try!(l.repr_js()), - op, - try!(r.repr_js()))), + BinExpr(op, ref l, ref r) => { + Ok(format!("({} {:?} {})", try!(l.repr_js()), op, try!(r.repr_js()))) + } Array(_) => Err("Array unimplemented".to_string()), } } -- cgit v1.2.3