@@ -46,13 +46,13 @@ impl<K: Ord, V> RBTree<K, V> {
4646 RBTree :: < K , V > { root : null_mut ( ) }
4747 }
4848
49- pub fn find ( & self , key : & K ) -> Option < & mut V > {
49+ pub fn find ( & self , key : & K ) -> Option < & V > {
5050 unsafe {
5151 let mut node = self . root ;
5252 while !node. is_null ( ) {
5353 node = match ( * node) . key . cmp ( key) {
5454 Ordering :: Less => ( * node) . right ,
55- Ordering :: Equal => return Some ( & mut ( * node) . value ) ,
55+ Ordering :: Equal => return Some ( & ( * node) . value ) ,
5656 Ordering :: Greater => ( * node) . left ,
5757 }
5858 }
@@ -619,10 +619,10 @@ mod tests {
619619 for ( k, v) in String :: from ( "hello, world!" ) . chars ( ) . enumerate ( ) {
620620 tree. insert ( k, v) ;
621621 }
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( & '*' ) , '!' ) ;
626626 }
627627
628628 #[ test]
0 commit comments