@@ -46,13 +46,13 @@ impl<K: Ord, V> RBTree<K, V> {
46
46
RBTree :: < K , V > { root : null_mut ( ) }
47
47
}
48
48
49
- pub fn find ( & self , key : & K ) -> Option < & mut V > {
49
+ pub fn find ( & self , key : & K ) -> Option < & V > {
50
50
unsafe {
51
51
let mut node = self . root ;
52
52
while !node. is_null ( ) {
53
53
node = match ( * node) . key . cmp ( key) {
54
54
Ordering :: Less => ( * node) . right ,
55
- Ordering :: Equal => return Some ( & mut ( * node) . value ) ,
55
+ Ordering :: Equal => return Some ( & ( * node) . value ) ,
56
56
Ordering :: Greater => ( * node) . left ,
57
57
}
58
58
}
@@ -619,10 +619,10 @@ mod tests {
619
619
for ( k, v) in String :: from ( "hello, world!" ) . chars ( ) . enumerate ( ) {
620
620
tree. insert ( k, v) ;
621
621
}
622
- assert_eq ! ( * tree. find( & 3 ) . unwrap_or( & mut '*' ) , 'l' ) ;
623
- assert_eq ! ( * tree. find( & 6 ) . unwrap_or( & mut '*' ) , ' ' ) ;
624
- assert_eq ! ( * tree. find( & 8 ) . unwrap_or( & mut '*' ) , 'o' ) ;
625
- assert_eq ! ( * tree. find( & 12 ) . unwrap_or( & mut '*' ) , '!' ) ;
622
+ assert_eq ! ( * tree. find( & 3 ) . unwrap_or( & '*' ) , 'l' ) ;
623
+ assert_eq ! ( * tree. find( & 6 ) . unwrap_or( & '*' ) , ' ' ) ;
624
+ assert_eq ! ( * tree. find( & 8 ) . unwrap_or( & '*' ) , 'o' ) ;
625
+ assert_eq ! ( * tree. find( & 12 ) . unwrap_or( & '*' ) , '!' ) ;
626
626
}
627
627
628
628
#[ test]
0 commit comments