Browse Source

adding conversions for usize (preperation for charAt implemetation)

pull/18/head
Jason Williams 6 years ago
parent
commit
df8e58212f
  1. 11
      src/lib/js/value.rs

11
src/lib/js/value.rs

@ -626,6 +626,17 @@ impl FromValue for i32 {
} }
} }
impl ToValue for usize {
fn to_value(&self) -> Value {
Gc::new(ValueData::Integer(*self as i32))
}
}
impl FromValue for usize {
fn from_value(v: Value) -> Result<usize, &'static str> {
Ok(v.to_int() as usize)
}
}
impl ToValue for bool { impl ToValue for bool {
fn to_value(&self) -> Value { fn to_value(&self) -> Value {
Gc::new(ValueData::Boolean(*self)) Gc::new(ValueData::Boolean(*self))

Loading…
Cancel
Save