@@ -19,7 +19,7 @@ pub use self::Entry::*;
1919
2020use core:: prelude:: * ;
2121
22- use core:: borrow:: { BorrowFrom , ToOwned } ;
22+ use core:: borrow:: BorrowFrom ;
2323use core:: cmp:: Ordering ;
2424use core:: default:: Default ;
2525use core:: fmt:: Show ;
@@ -128,24 +128,24 @@ pub struct Values<'a, K: 'a, V: 'a> {
128128 inner : Map < ( & ' a K , & ' a V ) , & ' a V , Iter < ' a , K , V > , fn ( ( & ' a K , & ' a V ) ) -> & ' a V >
129129}
130130
131- #[ stable]
132131/// A view into a single entry in a map, which may either be vacant or occupied.
133- pub enum Entry < ' a , Q : ?Sized +' a , K : ' a , V : ' a > {
132+ #[ unstable = "precise API still under development" ]
133+ pub enum Entry < ' a , K : ' a , V : ' a > {
134134 /// A vacant Entry
135- Vacant ( VacantEntry < ' a , Q , K , V > ) ,
135+ Vacant ( VacantEntry < ' a , K , V > ) ,
136136 /// An occupied Entry
137137 Occupied ( OccupiedEntry < ' a , K , V > ) ,
138138}
139139
140- #[ stable]
141140/// A vacant Entry.
142- pub struct VacantEntry < ' a , Q : ?Sized +' a , K : ' a , V : ' a > {
143- key : & ' a Q ,
141+ #[ unstable = "precise API still under development" ]
142+ pub struct VacantEntry < ' a , K : ' a , V : ' a > {
143+ key : K ,
144144 stack : stack:: SearchStack < ' a , K , V , node:: handle:: Edge , node:: handle:: Leaf > ,
145145}
146146
147- #[ stable]
148147/// An occupied Entry.
148+ #[ unstable = "precise API still under development" ]
149149pub struct OccupiedEntry < ' a , K : ' a , V : ' a > {
150150 stack : stack:: SearchStack < ' a , K , V , node:: handle:: KV , node:: handle:: LeafOrInternal > ,
151151}
@@ -1111,55 +1111,55 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
11111111#[ stable]
11121112impl < ' a , K , V > ExactSizeIterator for Values < ' a , K , V > { }
11131113
1114- impl < ' a , Q : ? Sized , K : Ord , V > Entry < ' a , Q , K , V > {
1114+ impl < ' a , K : Ord , V > Entry < ' a , K , V > {
11151115 #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11161116 /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
1117- pub fn get ( self ) -> Result < & ' a mut V , VacantEntry < ' a , Q , K , V > > {
1117+ pub fn get ( self ) -> Result < & ' a mut V , VacantEntry < ' a , K , V > > {
11181118 match self {
11191119 Occupied ( entry) => Ok ( entry. into_mut ( ) ) ,
11201120 Vacant ( entry) => Err ( entry) ,
11211121 }
11221122 }
11231123}
11241124
1125- impl < ' a , Q : ?Sized + ToOwned < K > , K : Ord , V > VacantEntry < ' a , Q , K , V > {
1126- #[ stable]
1125+ impl < ' a , K : Ord , V > VacantEntry < ' a , K , V > {
11271126 /// Sets the value of the entry with the VacantEntry's key,
11281127 /// and returns a mutable reference to it.
1128+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11291129 pub fn insert ( self , value : V ) -> & ' a mut V {
1130- self . stack . insert ( self . key . to_owned ( ) , value)
1130+ self . stack . insert ( self . key , value)
11311131 }
11321132}
11331133
11341134impl < ' a , K : Ord , V > OccupiedEntry < ' a , K , V > {
1135- #[ stable]
11361135 /// Gets a reference to the value in the entry.
1136+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11371137 pub fn get ( & self ) -> & V {
11381138 self . stack . peek ( )
11391139 }
11401140
1141- #[ stable]
11421141 /// Gets a mutable reference to the value in the entry.
1142+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11431143 pub fn get_mut ( & mut self ) -> & mut V {
11441144 self . stack . peek_mut ( )
11451145 }
11461146
1147- #[ stable]
11481147 /// Converts the entry into a mutable reference to its value.
1148+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11491149 pub fn into_mut ( self ) -> & ' a mut V {
11501150 self . stack . into_top ( )
11511151 }
11521152
1153- #[ stable]
11541153 /// Sets the value of the entry with the OccupiedEntry's key,
11551154 /// and returns the entry's old value.
1155+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11561156 pub fn insert ( & mut self , mut value : V ) -> V {
11571157 mem:: swap ( self . stack . peek_mut ( ) , & mut value) ;
11581158 value
11591159 }
11601160
1161- #[ stable]
11621161 /// Takes the value of the entry out of the map, and returns it.
1162+ #[ unstable = "matches collection reform v2 specification, waiting for dust to settle" ]
11631163 pub fn remove ( self ) -> V {
11641164 self . stack . remove ( )
11651165 }
@@ -1361,15 +1361,13 @@ impl<K: Ord, V> BTreeMap<K, V> {
13611361 /// assert_eq!(count["a"], 3u);
13621362 /// ```
13631363 /// The key must have the same ordering before or after `.to_owned()` is called.
1364- #[ stable]
1365- pub fn entry < ' a , Q : ?Sized > ( & ' a mut self , mut key : & ' a Q ) -> Entry < ' a , Q , K , V >
1366- where Q : Ord + ToOwned < K >
1367- {
1364+ #[ unstable = "precise API still under development" ]
1365+ pub fn entry < ' a > ( & ' a mut self , mut key : K ) -> Entry < ' a , K , V > {
13681366 // same basic logic of `swap` and `pop`, blended together
13691367 let mut stack = stack:: PartialSearchStack :: new ( self ) ;
13701368 loop {
13711369 let result = stack. with ( move |pusher, node| {
1372- return match Node :: search ( node, key) {
1370+ return match Node :: search ( node, & key) {
13731371 Found ( handle) => {
13741372 // Perfect match
13751373 Finished ( Occupied ( OccupiedEntry {
@@ -1412,7 +1410,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
14121410#[ cfg( test) ]
14131411mod test {
14141412 use prelude:: * ;
1415- use std:: borrow:: { ToOwned , BorrowFrom } ;
1413+ use std:: borrow:: BorrowFrom ;
14161414
14171415 use super :: { BTreeMap , Occupied , Vacant } ;
14181416
@@ -1562,7 +1560,7 @@ mod test {
15621560 let mut map: BTreeMap < int , int > = xs. iter ( ) . map ( |& x| x) . collect ( ) ;
15631561
15641562 // Existing key (insert)
1565- match map. entry ( & 1 ) {
1563+ match map. entry ( 1 ) {
15661564 Vacant ( _) => unreachable ! ( ) ,
15671565 Occupied ( mut view) => {
15681566 assert_eq ! ( view. get( ) , & 10 ) ;
@@ -1574,7 +1572,7 @@ mod test {
15741572
15751573
15761574 // Existing key (update)
1577- match map. entry ( & 2 ) {
1575+ match map. entry ( 2 ) {
15781576 Vacant ( _) => unreachable ! ( ) ,
15791577 Occupied ( mut view) => {
15801578 let v = view. get_mut ( ) ;
@@ -1585,7 +1583,7 @@ mod test {
15851583 assert_eq ! ( map. len( ) , 6 ) ;
15861584
15871585 // Existing key (take)
1588- match map. entry ( & 3 ) {
1586+ match map. entry ( 3 ) {
15891587 Vacant ( _) => unreachable ! ( ) ,
15901588 Occupied ( view) => {
15911589 assert_eq ! ( view. remove( ) , 30 ) ;
@@ -1596,7 +1594,7 @@ mod test {
15961594
15971595
15981596 // Inexistent key (insert)
1599- match map. entry ( & 10 ) {
1597+ match map. entry ( 10 ) {
16001598 Occupied ( _) => unreachable ! ( ) ,
16011599 Vacant ( view) => {
16021600 assert_eq ! ( * view. insert( 1000 ) , 1000 ) ;
0 commit comments