From 0909ca34fc801be0b1d4e850d1a00a4851e96405 Mon Sep 17 00:00:00 2001 From: kyren Date: Sun, 3 Dec 2017 18:25:53 -0500 Subject: [PATCH] auto formatting --- src/userdata.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/userdata.rs b/src/userdata.rs index 928405d..4c75852 100644 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -173,9 +173,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> { R: ToLuaMulti<'lua>, F: 'static + FnMut(&'lua Lua, A) -> Result, { - Box::new(move |lua, args| { - function(lua, A::from_lua_multi(args, lua)?)?.to_lua_multi(lua) - }) + Box::new(move |lua, args| function(lua, A::from_lua_multi(args, lua)?)?.to_lua_multi(lua)) } fn box_method(mut method: M) -> Callback<'lua> @@ -332,9 +330,8 @@ impl<'lua> AnyUserData<'lua> { /// Returns a `UserDataBorrowError` if the userdata is already mutably borrowed. Returns a /// `UserDataTypeMismatch` if the userdata is not of type `T`. pub fn borrow(&self) -> Result> { - self.inspect(|cell| { - Ok(cell.try_borrow().map_err(|_| Error::UserDataBorrowError)?) - }).ok_or(Error::UserDataTypeMismatch)? + self.inspect(|cell| Ok(cell.try_borrow().map_err(|_| Error::UserDataBorrowError)?)) + .ok_or(Error::UserDataTypeMismatch)? } /// Borrow this userdata mutably if it is of type `T`. @@ -463,14 +460,14 @@ mod tests { impl UserData for MyUserData { fn add_methods(methods: &mut UserDataMethods) { methods.add_method("get", |_, data, ()| Ok(data.0)); - methods - .add_meta_function(MetaMethod::Add, |_, (lhs, rhs): (MyUserData, MyUserData)| { - Ok(MyUserData(lhs.0 + rhs.0)) - }); - methods - .add_meta_function(MetaMethod::Sub, |_, (lhs, rhs): (MyUserData, MyUserData)| { - Ok(MyUserData(lhs.0 - rhs.0)) - }); + methods.add_meta_function( + MetaMethod::Add, + |_, (lhs, rhs): (MyUserData, MyUserData)| Ok(MyUserData(lhs.0 + rhs.0)), + ); + methods.add_meta_function( + MetaMethod::Sub, + |_, (lhs, rhs): (MyUserData, MyUserData)| Ok(MyUserData(lhs.0 - rhs.0)), + ); methods.add_meta_method(MetaMethod::Index, |_, data, index: String| { if index.to_str()? == "inner" { Ok(data.0)