/// This does the same thing as `set_global` but attempts to return the variable which was replaced
This does the same thing as `set_global` but attempts to return the variable which was replaced
This does the same thing as ` set_global ` but attempts to return the variable which was replaced
pub fn replace_global<K: ToString, V: Any, R: Any>(
        &mut self,
        key: K,
        value: V,
    ) -> Result<Option<Box<R>>, Trap> {
        match self.globals.insert(key.to_string(), Box::new(value)) {
            None => Ok(None),
            Some(val) => Ok(Some(
                val.downcast()
                    .map_err(|_| Trap::DowncastError(type_name::<R>()))?,
            )),
        }
    }
pub fn replace_global < K : ToString , V : Any , R : Any > ( & mut self , key : K , value : V , ) -> Result < Option < Box < R > > , Trap > { match self . globals . insert ( key . to_string ( ) , Box :: new ( value ) ) { None => Ok ( None ) , Some ( val ) => Ok ( Some ( val . downcast ( ) . map_err ( | _ | Trap :: DowncastError ( type_name :: < R > ( ) ) ) ? , ) ) , } }
This does the same thing as `set_global` but attempts to return the variable which was replaced
This does the same thing as ` set_global ` but attempts to return the variable which was replaced
&mut self
key
K
value
V