pub fn core_at(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "at requires two arguments");
            return 0;
        }

        let key_str_rr = self.stack.pop().unwrap();
        let key_str_rrb = key_str_rr.borrow();
        let key_str_pre = key_str_rrb.to_string();
        let key_str_opt = to_string_2(&key_str_pre);

        let hash_rr = self.stack.pop().unwrap();
        let hash_rrb = hash_rr.borrow();

        match (&*hash_rrb, key_str_opt) {
            (Value::Hash(map), Some(s)) => {
                let v = map.get(s);
                match v {
                    None => {
                        self.stack.push(Rc::new(RefCell::new(Value::Null)));
                    }
                    Some(r) => {
                        self.stack.push(r.clone());
                    }
                }
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first at argument must be hash");
                return 0;
            }
            _ => {
                print_error(chunk, i, "second at argument must be string");
                return 0;
            }
        }
        return 1;
    }
/// Takes a hash value and a key string as its arguments.  Puts
/// the value at that hash key onto the stack, or the null value
/// if no such hash key exists.
Takes a hash value and a key string as its arguments.  Puts
the value at that hash key onto the stack, or the null value
if no such hash key exists.
Takes a hash value and a key string as its arguments . Puts the value at that hash key onto the stack or the null value if no such hash key exists .
pub fn core_at(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "at requires two arguments");
            return 0;
        }
        let key_str_rr = self.stack.pop().unwrap();
        let key_str_rrb = key_str_rr.borrow();
        let key_str_pre = key_str_rrb.to_string();
        let key_str_opt = to_string_2(&key_str_pre);
        let hash_rr = self.stack.pop().unwrap();
        let hash_rrb = hash_rr.borrow();
        match (&*hash_rrb, key_str_opt) {
            (Value::Hash(map), Some(s)) => {
                let v = map.get(s);
                match v {
                    None => {
                        self.stack.push(Rc::new(RefCell::new(Value::Null)));
                    }
                    Some(r) => {
                        self.stack.push(r.clone());
                    }
                }
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first at argument must be hash");
                return 0;
            }
            _ => {
                print_error(chunk, i, "second at argument must be string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_at ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let key_str_rr = self . stack . pop ( ) . unwrap ( ) ; let key_str_rrb = key_str_rr . borrow ( ) ; let key_str_pre = key_str_rrb . to_string ( ) ; let key_str_opt = to_string_2 ( & key_str_pre ) ; let hash_rr = self . stack . pop ( ) . unwrap ( ) ; let hash_rrb = hash_rr . borrow ( ) ; match ( & * hash_rrb , key_str_opt ) { ( Value :: Hash ( map ) , Some ( s ) ) => { let v = map . get ( s ) ; match v { None => { self . stack . push ( Rc :: new ( RefCell :: new ( Value :: Null ) ) ) ; } Some ( r ) => { self . stack . push ( r . clone ( ) ) ; } } } ( _ , Some ( _ ) ) => { print_error ( chunk , i , " " ) ; return 0 ; } _ => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes a hash value and a key string as its arguments.
Takes a hash value and a key string as its arguments .
&mut self
chunk
&Chunk
i
usize