1
This commit is contained in:
parent
0da572a5fa
commit
1d17503122
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
target/
|
||||||
|
*.lock
|
@ -6,3 +6,7 @@ mod tests {
|
|||||||
assert_eq!(result, 4);
|
assert_eq!(result, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod xvalue;
|
||||||
|
|
||||||
|
pub use xvalue::XValue;
|
||||||
|
35
src/xvalue.rs
Normal file
35
src/xvalue.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
pub enum XValue<T> {
|
||||||
|
_IntVal(i64),
|
||||||
|
_UserData(T)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl<T> XValue<T> {
|
||||||
|
|
||||||
|
pub fn new() -> Self {
|
||||||
|
return XValue::<T>::_IntVal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_i64(&self) -> i64 {
|
||||||
|
match self {
|
||||||
|
XValue::_IntVal(v) => {
|
||||||
|
return *v;
|
||||||
|
},
|
||||||
|
XValue::_UserData(_v) => {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_i64(&mut self, val: i64) {
|
||||||
|
match self {
|
||||||
|
XValue::_IntVal(v) => {
|
||||||
|
*v = val;
|
||||||
|
},
|
||||||
|
XValue::_UserData(_v) => {
|
||||||
|
*self = XValue::<T>::_IntVal(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user