@@ -455,7 +455,9 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
455455/// flag: &'a Cell<bool>,
456456/// }
457457///
458- /// impl<'a> Deref<Node<uint, uint>> for Nasty<'a> {
458+ /// impl<'a> Deref for Nasty<'a> {
459+ /// type Target = Node<uint, uint>;
460+ ///
459461/// fn deref(&self) -> &Node<uint, uint> {
460462/// if self.flag.get() {
461463/// &*self.second
@@ -511,7 +513,7 @@ impl<K: Ord, V> Node<K, V> {
511513 /// Searches for the given key in the node. If it finds an exact match,
512514 /// `Found` will be yielded with the matching index. If it doesn't find an exact match,
513515 /// `GoDown` will be yielded with the index of the subtree the key must lie in.
514- pub fn search < Sized ? Q , NodeRef : Deref < Node < K , V > > > ( node : NodeRef , key : & Q )
516+ pub fn search < Sized ? Q , NodeRef : Deref < Target = Node < K , V > > > ( node : NodeRef , key : & Q )
515517 -> SearchResult < NodeRef > where Q : BorrowFrom < K > + Ord {
516518 // FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
517519 // For the B configured as of this writing (B = 6), binary search was *significantly*
@@ -588,7 +590,7 @@ impl <K, V> Node<K, V> {
588590 }
589591}
590592
591- impl < K , V , NodeRef : Deref < Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
593+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
592594 /// Returns a reference to the node that contains the pointed-to edge or key/value pair. This
593595 /// is very different from `edge` and `edge_mut` because those return children of the node
594596 /// returned by `node`.
@@ -597,7 +599,9 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type, NodeType> Handle<NodeRef, Type, Nod
597599 }
598600}
599601
600- impl < K , V , NodeRef : DerefMut < Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
602+ impl < K , V , NodeRef , Type , NodeType > Handle < NodeRef , Type , NodeType > where
603+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
604+ {
601605 /// Converts a handle into one that stores the same information using a raw pointer. This can
602606 /// be useful in conjunction with `from_raw` when the type system is insufficient for
603607 /// determining the lifetimes of the nodes.
@@ -653,7 +657,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal
653657 }
654658}
655659
656- impl < K , V , NodeRef : Deref < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
660+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
657661 // This doesn't exist because there are no uses for it,
658662 // but is fine to add, analagous to edge_mut.
659663 //
@@ -667,7 +671,7 @@ pub enum ForceResult<NodeRef, Type> {
667671 Internal ( Handle < NodeRef , Type , handle:: Internal > )
668672}
669673
670- impl < K , V , NodeRef : Deref < Node < K , V > > , Type > Handle < NodeRef , Type , handle:: LeafOrInternal > {
674+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > , Type > Handle < NodeRef , Type , handle:: LeafOrInternal > {
671675 /// Figure out whether this handle is pointing to something in a leaf node or to something in
672676 /// an internal node, clarifying the type according to the result.
673677 pub fn force ( self ) -> ForceResult < NodeRef , Type > {
@@ -684,8 +688,9 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafO
684688 }
685689 }
686690}
687-
688- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Leaf > {
691+ impl < K , V , NodeRef > Handle < NodeRef , handle:: Edge , handle:: Leaf > where
692+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
693+ {
689694 /// Tries to insert this key-value pair at the given index in this leaf node
690695 /// If the node is full, we have to split it.
691696 ///
@@ -717,7 +722,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
717722 }
718723}
719724
720- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
725+ impl < K , V , NodeRef > Handle < NodeRef , handle:: Edge , handle:: Internal > where
726+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
727+ {
721728 /// Returns a mutable reference to the edge pointed-to by this handle. This should not be
722729 /// confused with `node`, which references the parent node of what is returned here.
723730 pub fn edge_mut ( & mut self ) -> & mut Node < K , V > {
@@ -800,7 +807,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
800807 }
801808}
802809
803- impl < K , V , NodeRef : DerefMut < Node < K , V > > , NodeType > Handle < NodeRef , handle:: Edge , NodeType > {
810+ impl < K , V , NodeRef , NodeType > Handle < NodeRef , handle:: Edge , NodeType > where
811+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
812+ {
804813 /// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
805814 /// This is unsafe because the handle might point to the first edge in the node, which has no
806815 /// pair to its left.
@@ -862,7 +871,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
862871 }
863872}
864873
865- impl < ' a , K : ' a , V : ' a , NodeRef : Deref < Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
874+ impl < ' a , K : ' a , V : ' a , NodeRef : Deref < Target = Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
866875 NodeType > {
867876 // These are fine to include, but are currently unneeded.
868877 //
@@ -881,8 +890,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
881890 // }
882891}
883892
884- impl < ' a , K : ' a , V : ' a , NodeRef : DerefMut < Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
885- NodeType > {
893+ impl < ' a , K : ' a , V : ' a , NodeRef , NodeType > Handle < NodeRef , handle:: KV , NodeType > where
894+ NodeRef : ' a + Deref < Target =Node < K , V > > + DerefMut ,
895+ {
886896 /// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
887897 /// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
888898 /// handle.
@@ -898,7 +908,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
898908 }
899909}
900910
901- impl < K , V , NodeRef : DerefMut < Node < K , V > > , NodeType > Handle < NodeRef , handle:: KV , NodeType > {
911+ impl < K , V , NodeRef , NodeType > Handle < NodeRef , handle:: KV , NodeType > where
912+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
913+ {
902914 /// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
903915 /// to by this handle.
904916 pub fn left_edge < ' a > ( & ' a mut self ) -> Handle < & ' a mut Node < K , V > , handle:: Edge , NodeType > {
@@ -918,7 +930,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV,
918930 }
919931}
920932
921- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: KV , handle:: Leaf > {
933+ impl < K , V , NodeRef > Handle < NodeRef , handle:: KV , handle:: Leaf > where
934+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
935+ {
922936 /// Removes the key/value pair at the handle's location.
923937 ///
924938 /// # Panics (in debug build)
@@ -929,7 +943,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Le
929943 }
930944}
931945
932- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: KV , handle:: Internal > {
946+ impl < K , V , NodeRef > Handle < NodeRef , handle:: KV , handle:: Internal > where
947+ NodeRef : Deref < Target =Node < K , V > > + DerefMut
948+ {
933949 /// Steal! Stealing is roughly analogous to a binary tree rotation.
934950 /// In this case, we're "rotating" right.
935951 unsafe fn steal_rightward ( & mut self ) {
0 commit comments