fn eq(&self, other: &JumpRope) -> bool {
        if self.num_bytes != other.num_bytes
                || self.len_chars() != other.len_chars() {
            return false
        }

        let mut other_iter = other.chunks().strings();

        // let mut os = other_iter.next();
        let mut os = "";

        for mut s in self.chunks().strings() {
            // Walk s.len() bytes through the other rope
            while !s.is_empty() {
                if os.is_empty() {
                    os = other_iter.next().unwrap();
                }
                debug_assert!(!os.is_empty());

                let amt = min(s.len(), os.len());
                debug_assert!(amt > 0);

                let (s_start, s_rem) = s.split_at(amt);
                let (os_start, os_rem) = os.split_at(amt);

                if s_start != os_start { return false; }

                s = s_rem;
                os = os_rem;
            }
        }

        true
    }
// Another way to implement this would be to rewrite it as a comparison with
// an iterator over &str. Then the rope vs rope comparison would be trivial,
// but also we could add comparison functions with a single &str and stuff
// very easily.
Another way to implement this would be to rewrite it as a comparison with
an iterator over &str. Then the rope vs rope comparison would be trivial,
but also we could add comparison functions with a single &str and stuff
very easily.
Another way to implement this would be to rewrite it as a comparison with an iterator over &str . Then the rope vs rope comparison would be trivial but also we could add comparison functions with a single &str and stuff very easily .
fn eq(&self, other: &JumpRope) -> bool {
        if self.num_bytes != other.num_bytes
                || self.len_chars() != other.len_chars() {
            return false
        }
        let mut other_iter = other.chunks().strings();
        // let mut os = other_iter.next();
        let mut os = "";
        for mut s in self.chunks().strings() {
            // Walk s.len() bytes through the other rope
            while !s.is_empty() {
                if os.is_empty() {
                    os = other_iter.next().unwrap();
                }
                debug_assert!(!os.is_empty());
                let amt = min(s.len(), os.len());
                debug_assert!(amt > 0);
                let (s_start, s_rem) = s.split_at(amt);
                let (os_start, os_rem) = os.split_at(amt);
                if s_start != os_start { return false; }
                s = s_rem;
                os = os_rem;
            }
        }
        true
    }
fn eq ( & self , other : & JumpRope ) -> bool { if self . num_bytes != other . num_bytes || self . len_chars ( ) != other . len_chars ( ) { return false } let mut other_iter = other . chunks ( ) . strings ( ) ; // let mut os = other_iter.next(); let mut os = " " ; for mut s in self . chunks ( ) . strings ( ) { // Walk s.len() bytes through the other rope while ! s . is_empty ( ) { if os . is_empty ( ) { os = other_iter . next ( ) . unwrap ( ) ; } debug_assert ! ( os is_empty ( ) ) ; let amt = min ( s . len ( ) , os . len ( ) ) ; debug_assert ! ( amt 0 ) ; let ( s_start , s_rem ) = s . split_at ( amt ) ; let ( os_start , os_rem ) = os . split_at ( amt ) ; if s_start != os_start { return false ; } s = s_rem ; os = os_rem ; } } true }
Another way to implement this would be to rewrite it as a comparison with
an iterator over &str.
Another way to implement this would be to rewrite it as a comparison with an iterator over &str .
&self
other
&JumpRope