Module lua::values[−][src]

Implementations of FromLua and IntoLua for rust primitives.

Example

extern crate lua;

use lua::Index;

let mut state = lua::State::new();

state.push("128").unwrap(); // Index::Top(4)
state.push_nil().unwrap();  // Index::Top(3)
state.push(16).unwrap();    // Index::Top(2)
state.push(true).unwrap();  // Index::Top(1)

// Numeric
assert_eq!(Ok(128), state.get(-4));
assert_eq!(Ok(16), state.get(-2));
assert_eq!(Ok(16.0), state.get(-2));

// Booleans return true for any value that is not `nil`
assert_eq!(Ok(true), state.get(-1));
assert_eq!(Ok(false), state.get(-3));

// Some values can also be read as strings. Because string
// in lua can contain arbitrary binary data, the `FromLua`
// trait is implemented for both &str and [u8] slices
assert_eq!(Ok("16.0"), state.get(-2));