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

        let v1 = self.stack.pop().unwrap();
        let v1_b = v1.borrow();
        let v2 = self.stack.pop().unwrap();
        let v2_b = v2.borrow();

        let v1_str_pre = v1_b.to_string();
        let v1_str_opt = to_string_2(&v1_str_pre);
        let v2_str_pre = v2_b.to_string();
        let v2_str_opt = to_string_2(&v2_str_pre);

        match (v1_str_opt, v2_str_opt) {
            (Some(s1), Some(s2)) => {
                let s3 = format!("{}{}", s2, s1);
                self.stack
                    .push(Rc::new(RefCell::new(Value::String(s3, None))));
            }
            (Some(_), _) => {
                print_error(chunk, i, "second append argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "first append argument must be string");
                return 0;
            }
        }
        return 1;
    }
/// Takes two string arguments, appends them together, and adds
/// the resulting string back onto the stack.
Takes two string arguments, appends them together, and adds
the resulting string back onto the stack.
Takes two string arguments appends them together and adds the resulting string back onto the stack .
pub fn core_append(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "append requires two arguments");
            return 0;
        }
        let v1 = self.stack.pop().unwrap();
        let v1_b = v1.borrow();
        let v2 = self.stack.pop().unwrap();
        let v2_b = v2.borrow();
        let v1_str_pre = v1_b.to_string();
        let v1_str_opt = to_string_2(&v1_str_pre);
        let v2_str_pre = v2_b.to_string();
        let v2_str_opt = to_string_2(&v2_str_pre);
        match (v1_str_opt, v2_str_opt) {
            (Some(s1), Some(s2)) => {
                let s3 = format!("{}{}", s2, s1);
                self.stack
                    .push(Rc::new(RefCell::new(Value::String(s3, None))));
            }
            (Some(_), _) => {
                print_error(chunk, i, "second append argument must be string");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "first append argument must be string");
                return 0;
            }
        }
        return 1;
    }
pub fn core_append ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let v1 = self . stack . pop ( ) . unwrap ( ) ; let v1_b = v1 . borrow ( ) ; let v2 = self . stack . pop ( ) . unwrap ( ) ; let v2_b = v2 . borrow ( ) ; let v1_str_pre = v1_b . to_string ( ) ; let v1_str_opt = to_string_2 ( & v1_str_pre ) ; let v2_str_pre = v2_b . to_string ( ) ; let v2_str_opt = to_string_2 ( & v2_str_pre ) ; match ( v1_str_opt , v2_str_opt ) { ( Some ( s1 ) , Some ( s2 ) ) => { let s3 = format ! ( " " s2 s1 ) ; self . stack . push ( Rc :: new ( RefCell :: new ( Value :: String ( s3 , None ) ) ) ) ; } ( Some ( _ ) , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } ( _ , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } } return 1 ; }
Takes two string arguments, appends them together, and adds
the resulting string back onto the stack.
Takes two string arguments appends them together and adds the resulting string back onto the stack .
&mut self
chunk
&Chunk
i
usize