@@ -455,7 +455,9 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
455
455
/// flag: &'a Cell<bool>,
456
456
/// }
457
457
///
458
- /// impl<'a> Deref<Node<uint, uint>> for Nasty<'a> {
458
+ /// impl<'a> Deref for Nasty<'a> {
459
+ /// type Target = Node<uint, uint>;
460
+ ///
459
461
/// fn deref(&self) -> &Node<uint, uint> {
460
462
/// if self.flag.get() {
461
463
/// &*self.second
@@ -511,7 +513,7 @@ impl<K: Ord, V> Node<K, V> {
511
513
/// Searches for the given key in the node. If it finds an exact match,
512
514
/// `Found` will be yielded with the matching index. If it doesn't find an exact match,
513
515
/// `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 )
515
517
-> SearchResult < NodeRef > where Q : BorrowFrom < K > + Ord {
516
518
// FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
517
519
// For the B configured as of this writing (B = 6), binary search was *significantly*
@@ -588,7 +590,7 @@ impl <K, V> Node<K, V> {
588
590
}
589
591
}
590
592
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 > {
592
594
/// Returns a reference to the node that contains the pointed-to edge or key/value pair. This
593
595
/// is very different from `edge` and `edge_mut` because those return children of the node
594
596
/// returned by `node`.
@@ -597,7 +599,9 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type, NodeType> Handle<NodeRef, Type, Nod
597
599
}
598
600
}
599
601
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
+ {
601
605
/// Converts a handle into one that stores the same information using a raw pointer. This can
602
606
/// be useful in conjunction with `from_raw` when the type system is insufficient for
603
607
/// 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
653
657
}
654
658
}
655
659
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 > {
657
661
// This doesn't exist because there are no uses for it,
658
662
// but is fine to add, analagous to edge_mut.
659
663
//
@@ -667,7 +671,7 @@ pub enum ForceResult<NodeRef, Type> {
667
671
Internal ( Handle < NodeRef , Type , handle:: Internal > )
668
672
}
669
673
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 > {
671
675
/// Figure out whether this handle is pointing to something in a leaf node or to something in
672
676
/// an internal node, clarifying the type according to the result.
673
677
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
684
688
}
685
689
}
686
690
}
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
+ {
689
694
/// Tries to insert this key-value pair at the given index in this leaf node
690
695
/// If the node is full, we have to split it.
691
696
///
@@ -717,7 +722,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
717
722
}
718
723
}
719
724
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
+ {
721
728
/// Returns a mutable reference to the edge pointed-to by this handle. This should not be
722
729
/// confused with `node`, which references the parent node of what is returned here.
723
730
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::
800
807
}
801
808
}
802
809
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
+ {
804
813
/// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
805
814
/// This is unsafe because the handle might point to the first edge in the node, which has no
806
815
/// pair to its left.
@@ -862,7 +871,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
862
871
}
863
872
}
864
873
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 ,
866
875
NodeType > {
867
876
// These are fine to include, but are currently unneeded.
868
877
//
@@ -881,8 +890,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
881
890
// }
882
891
}
883
892
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
+ {
886
896
/// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
887
897
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
888
898
/// handle.
@@ -898,7 +908,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
898
908
}
899
909
}
900
910
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
+ {
902
914
/// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
903
915
/// to by this handle.
904
916
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,
918
930
}
919
931
}
920
932
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
+ {
922
936
/// Removes the key/value pair at the handle's location.
923
937
///
924
938
/// # Panics (in debug build)
@@ -929,7 +943,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Le
929
943
}
930
944
}
931
945
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
+ {
933
949
/// Steal! Stealing is roughly analogous to a binary tree rotation.
934
950
/// In this case, we're "rotating" right.
935
951
unsafe fn steal_rightward ( & mut self ) {
0 commit comments