fn memoize(&mut self, memo_id: MemoId) -> Result<()> {
        let mut item = self.pop()?;
        if let Value::MemoRef(id) = item {
            // TODO: is this even possible?
            item = match self.memo.get(&id) {
                Some(&(ref v, _)) => v.clone(),
                None => return Err(Error::Eval(ErrorCode::MissingMemo(id), self.pos)),
            };
        }
        self.memo.insert(memo_id, (item, 1));
        self.stack.push(Value::MemoRef(memo_id));
        Ok(())
    }
// Memoize the current stack top with the given ID.  Moves the actual
// object into the memo, and saves a reference on the stack instead.
Memoize the current stack top with the given ID.  Moves the actual
object into the memo, and saves a reference on the stack instead.
Memoize the current stack top with the given ID . Moves the actual object into the memo and saves a reference on the stack instead .
fn memoize(&mut self, memo_id: MemoId) -> Result<()> {
        let mut item = self.pop()?;
        if let Value::MemoRef(id) = item {
            // TODO: is this even possible?
            item = match self.memo.get(&id) {
                Some(&(ref v, _)) => v.clone(),
                None => return Err(Error::Eval(ErrorCode::MissingMemo(id), self.pos)),
            };
        }
        self.memo.insert(memo_id, (item, 1));
        self.stack.push(Value::MemoRef(memo_id));
        Ok(())
    }
fn memoize ( & mut self , memo_id : MemoId ) -> Result < ( ) > { let mut item = self . pop ( ) ? ; if let Value :: MemoRef ( id ) = item { // TODO: is this even possible? item = match self . memo . get ( & id ) { Some ( & ( ref v , _ ) ) => v . clone ( ) , None => return Err ( Error :: Eval ( ErrorCode :: MissingMemo ( id ) , self . pos ) ) , } ; } self . memo . insert ( memo_id , ( item , 1 ) ) ; self . stack . push ( Value :: MemoRef ( memo_id ) ) ; Ok ( ( ) ) }
Memoize the current stack top with the given ID.
Memoize the current stack top with the given ID .
&mut self
memo_id
MemoId
&mut self
memo_id
MemoId