From df8e58212f9d7bf10d349d6bc03e5930395aaa39 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Thu, 21 Mar 2019 23:21:16 +0000 Subject: [PATCH] adding conversions for usize (preperation for charAt implemetation) --- src/lib/js/value.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/js/value.rs b/src/lib/js/value.rs index 250d533fcc..44e722a5d5 100644 --- a/src/lib/js/value.rs +++ b/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 { + Ok(v.to_int() as usize) + } +} + impl ToValue for bool { fn to_value(&self) -> Value { Gc::new(ValueData::Boolean(*self))