1use lua::{Index, ToLua, FromLua, State};
2use types::{LuaStackable};
3
4pub struct LuaNil {
6 index: Index
7}
8
9impl LuaNil {
10 pub fn new(i: Index) -> LuaNil {
12 LuaNil {
13 index: i
14 }
15 }
16}
17
18impl LuaStackable for LuaNil {
19 fn get_pos(&self) -> Index {
20 self.index
21 }
22}
23
24impl ToLua for LuaNil {
25 fn to_lua(&self, state: &mut State) {
26 state.push_value(self.get_pos());
27 }
28}
29
30impl FromLua for LuaNil {
31 fn from_lua(state: &mut State, index: Index) -> Option<LuaNil> {
32 if state.is_nil(index) {
33 Some(LuaNil::new(index))
34 } else {
35 None
36 }
37 }
38}