diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/examples.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/examples.rs b/examples/examples.rs index 6bd7738..28f5dbf 100644 --- a/examples/examples.rs +++ b/examples/examples.rs @@ -2,6 +2,8 @@ extern crate hlist_macro; extern crate rlua; +use std::f32; + use rlua::*; fn examples() -> LuaResult<()> { @@ -128,8 +130,8 @@ fn examples() -> LuaResult<()> { assert_eq!(lua.eval::<String>(r#"join("a", "b", "c")"#)?, "abc"); // You can create userdata with methods and metamethods defined on them. - // Here's a more complete example that shows all of the features of this API - // together + // Here's a more complete example that shows many of the features of this + // API together #[derive(Copy, Clone)] struct Vec2(f32, f32); @@ -154,10 +156,7 @@ fn examples() -> LuaResult<()> { })?; globals.set("vec2", vec2_constructor)?; - assert_eq!( - lua.eval::<f32>("(vec2(1, 2) + vec2(2, 2)):magnitude()")?, - 5.0 - ); + assert!(lua.eval::<f32>("(vec2(1, 2) + vec2(2, 2)):magnitude()")? - 5.0 < f32::EPSILON); Ok(()) } |