3030//! ```ignore
3131//!
3232//! impl<'a> SlFromRef<'a, Value> for &'a str {
33- //! fn sl_from_ref(value: Value, vm: &'a SloshVm) -> VMResult <Self> {
33+ //! fn sl_from_ref(value: Value, vm: &'a SloshVm) -> BridgeResult <Self> {
3434//! (&value).sl_as_ref(vm)
3535//! }
3636//! }
3737//!
3838//! impl<'a> SlAsRef<'a, str> for &Value {
39- //! fn sl_as_ref(&self, vm: &'a SloshVm) -> VMResult <&'a str> {
39+ //! fn sl_as_ref(&self, vm: &'a SloshVm) -> BridgeResult <&'a str> {
4040//! match self {
4141//! Value::String(h) => Ok(vm.get_string(*h)),
4242//! Value::StringConst(i) => Ok(vm.get_interned(*i)),
4343//! _ => Err(VMError::new_conversion(
44- //! ErrorStrings::fix_me_mismatched_type (
44+ //! ErrorStrings::mismatched_type (
4545//! String::from(ValueTypes::from([
4646//! ValueType::String,
4747//! ValueType::StringConst,
6060//! ```ignore
6161//!
6262//! impl<'a> SlFromRefMut<'a, Value> for &'a mut String {
63- //! fn sl_from_ref_mut(value: Value, vm: &'a mut SloshVm) -> VMResult <Self> {
63+ //! fn sl_from_ref_mut(value: Value, vm: &'a mut SloshVm) -> BridgeResult <Self> {
6464//! (&value).sl_as_mut(vm)
6565//! }
6666//! }
6767//!
6868//! impl<'a> SlAsMut<'a, String> for &Value {
69- //! fn sl_as_mut(&mut self, vm: &'a mut SloshVm) -> VMResult <&'a mut String> {
69+ //! fn sl_as_mut(&mut self, vm: &'a mut SloshVm) -> BridgeResult <&'a mut String> {
7070//! match self {
7171//! Value::String(h) => vm.get_string_mut(*h),
7272//! _ => Err(VMError::new_conversion(
73- //! ErrorStrings::fix_me_mismatched_type (
73+ //! ErrorStrings::mismatched_type (
7474//! <&'static str>::from(ValueType::String),
7575//! self.display_type(vm),
7676//! ),
101101//! TODO #220 - returning values via annotated or lifetime?
102102//! To avoid allocations when converting a slosh &Value back to a rust type that was mutated
103103//! don't return anything. If it is necessary for the API to return some value.
104- //! ...either use an annotation on an input argument `fn myfun(#[likeThis] returnme: &mut String, someotherval: String) -> VMResult <()>`
104+ //! ...either use an annotation on an input argument `fn myfun(#[likeThis] returnme: &mut String, someotherval: String) -> BridgeResult <()>`
105105//! or a lifetime... might be easier to do the annotation.
106106//!
107107//!
@@ -243,7 +243,9 @@ use bridge_types::BridgedType;
243243use bridge_types:: { Keyword , KeywordAsString , LooseString , SloshChar , Symbol , SymbolAsString } ;
244244use compile_state:: state:: SloshVm ;
245245
246- use slvm:: { VMResult , Value } ;
246+ use crate :: BridgeResult ;
247+ use slvm:: Value ;
248+
247249mod collections;
248250pub mod numbers;
249251pub mod primitives;
@@ -255,14 +257,14 @@ where
255257 Self : BridgedType ,
256258{
257259 /// Converts to this type from the input type.
258- fn sl_from ( value : T , vm : & mut SloshVm ) -> VMResult < Self > ;
260+ fn sl_from ( value : T , vm : & mut SloshVm ) -> BridgeResult < Self > ;
259261}
260262
261263impl < T > SlFrom < Vec < T > > for Value
262264where
263265 T : SlInto < Value > ,
264266{
265- fn sl_from ( value : Vec < T > , vm : & mut SloshVm ) -> VMResult < Self > {
267+ fn sl_from ( value : Vec < T > , vm : & mut SloshVm ) -> BridgeResult < Self > {
266268 let mut u = Vec :: with_capacity ( value. len ( ) ) ;
267269 for v in value {
268270 u. push ( v. sl_into ( vm) ?) ;
@@ -275,7 +277,7 @@ impl<'a, T> SlFromRef<'a, slvm::Value> for Vec<T>
275277where
276278 T : SlFromRef < ' a , Value > + ' a ,
277279{
278- fn sl_from_ref ( value : slvm:: Value , vm : & ' a SloshVm ) -> VMResult < Self > {
280+ fn sl_from_ref ( value : slvm:: Value , vm : & ' a SloshVm ) -> BridgeResult < Self > {
279281 let mut res = vec ! [ ] ;
280282 for val in value. iter ( vm) {
281283 let t: T = val. sl_into_ref ( vm) ?;
@@ -291,14 +293,14 @@ where
291293 T : BridgedType ,
292294{
293295 /// Converts this type into the (usually inferred) input type.
294- fn sl_into ( self , vm : & mut SloshVm ) -> VMResult < T > ;
296+ fn sl_into ( self , vm : & mut SloshVm ) -> BridgeResult < T > ;
295297}
296298
297299impl < T , U > SlInto < U > for T
298300where
299301 U : SlFrom < T > ,
300302{
301- fn sl_into ( self , vm : & mut SloshVm ) -> VMResult < U > {
303+ fn sl_into ( self , vm : & mut SloshVm ) -> BridgeResult < U > {
302304 U :: sl_from ( self , vm)
303305 }
304306}
@@ -308,7 +310,7 @@ where
308310 Self : Sized ,
309311{
310312 /// Converts to this type from the input type.
311- fn sl_from_ref ( value : T , vm : & ' a SloshVm ) -> VMResult < Self > ;
313+ fn sl_from_ref ( value : T , vm : & ' a SloshVm ) -> BridgeResult < Self > ;
312314}
313315
314316/// Inverse of [`SlFromRef`]
@@ -318,7 +320,7 @@ where
318320 Self : BridgedType ,
319321{
320322 /// Converts to this type from the input type.
321- fn sl_into_ref ( self , vm : & ' a SloshVm ) -> VMResult < T > ;
323+ fn sl_into_ref ( self , vm : & ' a SloshVm ) -> BridgeResult < T > ;
322324}
323325
324326impl < ' a , T , U > SlIntoRef < ' a , U > for T
@@ -327,7 +329,7 @@ where
327329 U : SlFromRef < ' a , T > ,
328330 U : ' a ,
329331{
330- fn sl_into_ref ( self , vm : & ' a SloshVm ) -> VMResult < U > {
332+ fn sl_into_ref ( self , vm : & ' a SloshVm ) -> BridgeResult < U > {
331333 U :: sl_from_ref ( self , vm)
332334 }
333335}
@@ -337,7 +339,7 @@ where
337339 Self : Sized ,
338340{
339341 /// Converts to this type from the input type.
340- fn sl_from_ref_mut ( value : T , vm : & ' a mut SloshVm ) -> VMResult < Self > ;
342+ fn sl_from_ref_mut ( value : T , vm : & ' a mut SloshVm ) -> BridgeResult < Self > ;
341343}
342344
343345/// Inverse of [`SlFromRefMut`]
@@ -347,7 +349,7 @@ where
347349 Self : BridgedType ,
348350{
349351 /// Converts to this type from the input type.
350- fn sl_into_ref_mut ( self , vm : & ' a mut SloshVm ) -> VMResult < T > ;
352+ fn sl_into_ref_mut ( self , vm : & ' a mut SloshVm ) -> BridgeResult < T > ;
351353}
352354
353355impl < ' a , T , U > SlIntoRefMut < ' a , U > for T
@@ -356,7 +358,7 @@ where
356358 U : SlFromRefMut < ' a , T > ,
357359 U : ' a ,
358360{
359- fn sl_into_ref_mut ( self , vm : & ' a mut SloshVm ) -> VMResult < U > {
361+ fn sl_into_ref_mut ( self , vm : & ' a mut SloshVm ) -> BridgeResult < U > {
360362 U :: sl_from_ref_mut ( self , vm)
361363 }
362364}
@@ -367,7 +369,7 @@ where
367369 Self : BridgedType ,
368370{
369371 /// Converts this type into a shared reference of the (usually inferred) input type.
370- fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> VMResult < & ' a T > ;
372+ fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> BridgeResult < & ' a T > ;
371373}
372374
373375// SlAsRef lifts over &
@@ -377,7 +379,7 @@ where
377379 & ' a T : BridgedType ,
378380{
379381 #[ inline]
380- fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> VMResult < & ' a U > {
382+ fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> BridgeResult < & ' a U > {
381383 <T as SlAsRef < ' a , U > >:: sl_as_ref ( * self , vm)
382384 }
383385}
@@ -389,7 +391,7 @@ where
389391 & ' a mut T : BridgedType ,
390392{
391393 #[ inline]
392- fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> VMResult < & ' a U > {
394+ fn sl_as_ref ( & self , vm : & ' a SloshVm ) -> BridgeResult < & ' a U > {
393395 <T as SlAsRef < ' a , U > >:: sl_as_ref ( * self , vm)
394396 }
395397}
@@ -399,7 +401,7 @@ where
399401 Self : BridgedType ,
400402{
401403 /// Converts this type into a mutable reference of the (usually inferred) input type.
402- fn sl_as_mut ( & mut self , vm : & ' a mut SloshVm ) -> VMResult < & ' a mut T > ;
404+ fn sl_as_mut ( & mut self , vm : & ' a mut SloshVm ) -> BridgeResult < & ' a mut T > ;
403405}
404406
405407// SlAsMut lifts over &mut
@@ -409,13 +411,13 @@ where
409411 & ' a mut T : BridgedType ,
410412{
411413 #[ inline]
412- fn sl_as_mut ( & mut self , vm : & ' a mut SloshVm ) -> VMResult < & ' a mut U > {
414+ fn sl_as_mut ( & mut self , vm : & ' a mut SloshVm ) -> BridgeResult < & ' a mut U > {
413415 ( * self ) . sl_as_mut ( vm)
414416 }
415417}
416418
417419impl SlFrom < Value > for Value {
418- fn sl_from ( value : Value , _vm : & mut SloshVm ) -> VMResult < Self > {
420+ fn sl_from ( value : Value , _vm : & mut SloshVm ) -> BridgeResult < Self > {
419421 Ok ( value)
420422 }
421423}
0 commit comments