@@ -457,7 +457,9 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
457
457
/// flag: &'a Cell<bool>,
458
458
/// }
459
459
///
460
- /// impl<'a> Deref<Node<uint, uint>> for Nasty<'a> {
460
+ /// impl<'a> Deref for Nasty<'a> {
461
+ /// type Target = Node<uint, uint>;
462
+ ///
461
463
/// fn deref(&self) -> &Node<uint, uint> {
462
464
/// if self.flag.get() {
463
465
/// &*self.second
@@ -513,7 +515,7 @@ impl<K: Ord, V> Node<K, V> {
513
515
/// Searches for the given key in the node. If it finds an exact match,
514
516
/// `Found` will be yielded with the matching index. If it doesn't find an exact match,
515
517
/// `GoDown` will be yielded with the index of the subtree the key must lie in.
516
- pub fn search < Sized ? Q , NodeRef : Deref < Node < K , V > > > ( node : NodeRef , key : & Q )
518
+ pub fn search < Sized ? Q , NodeRef : Deref < Target = Node < K , V > > > ( node : NodeRef , key : & Q )
517
519
-> SearchResult < NodeRef > where Q : BorrowFrom < K > + Ord {
518
520
// FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
519
521
// For the B configured as of this writing (B = 6), binary search was *significantly*
@@ -590,7 +592,7 @@ impl <K, V> Node<K, V> {
590
592
}
591
593
}
592
594
593
- impl < K , V , NodeRef : Deref < Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
595
+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
594
596
/// Returns a reference to the node that contains the pointed-to edge or key/value pair. This
595
597
/// is very different from `edge` and `edge_mut` because those return children of the node
596
598
/// returned by `node`.
@@ -599,7 +601,9 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type, NodeType> Handle<NodeRef, Type, Nod
599
601
}
600
602
}
601
603
602
- impl < K , V , NodeRef : DerefMut < Node < K , V > > , Type , NodeType > Handle < NodeRef , Type , NodeType > {
604
+ impl < K , V , NodeRef , Type , NodeType > Handle < NodeRef , Type , NodeType > where
605
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
606
+ {
603
607
/// Converts a handle into one that stores the same information using a raw pointer. This can
604
608
/// be useful in conjunction with `from_raw` when the type system is insufficient for
605
609
/// determining the lifetimes of the nodes.
@@ -655,7 +659,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal
655
659
}
656
660
}
657
661
658
- impl < K , V , NodeRef : Deref < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
662
+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
659
663
// This doesn't exist because there are no uses for it,
660
664
// but is fine to add, analagous to edge_mut.
661
665
//
@@ -669,7 +673,7 @@ pub enum ForceResult<NodeRef, Type> {
669
673
Internal ( Handle < NodeRef , Type , handle:: Internal > )
670
674
}
671
675
672
- impl < K , V , NodeRef : Deref < Node < K , V > > , Type > Handle < NodeRef , Type , handle:: LeafOrInternal > {
676
+ impl < K , V , NodeRef : Deref < Target = Node < K , V > > , Type > Handle < NodeRef , Type , handle:: LeafOrInternal > {
673
677
/// Figure out whether this handle is pointing to something in a leaf node or to something in
674
678
/// an internal node, clarifying the type according to the result.
675
679
pub fn force ( self ) -> ForceResult < NodeRef , Type > {
@@ -686,8 +690,9 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafO
686
690
}
687
691
}
688
692
}
689
-
690
- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Leaf > {
693
+ impl < K , V , NodeRef > Handle < NodeRef , handle:: Edge , handle:: Leaf > where
694
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
695
+ {
691
696
/// Tries to insert this key-value pair at the given index in this leaf node
692
697
/// If the node is full, we have to split it.
693
698
///
@@ -719,7 +724,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
719
724
}
720
725
}
721
726
722
- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: Edge , handle:: Internal > {
727
+ impl < K , V , NodeRef > Handle < NodeRef , handle:: Edge , handle:: Internal > where
728
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
729
+ {
723
730
/// Returns a mutable reference to the edge pointed-to by this handle. This should not be
724
731
/// confused with `node`, which references the parent node of what is returned here.
725
732
pub fn edge_mut ( & mut self ) -> & mut Node < K , V > {
@@ -802,7 +809,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::
802
809
}
803
810
}
804
811
805
- impl < K , V , NodeRef : DerefMut < Node < K , V > > , NodeType > Handle < NodeRef , handle:: Edge , NodeType > {
812
+ impl < K , V , NodeRef , NodeType > Handle < NodeRef , handle:: Edge , NodeType > where
813
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
814
+ {
806
815
/// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
807
816
/// This is unsafe because the handle might point to the first edge in the node, which has no
808
817
/// pair to its left.
@@ -864,7 +873,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
864
873
}
865
874
}
866
875
867
- impl < ' a , K : ' a , V : ' a , NodeRef : Deref < Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
876
+ impl < ' a , K : ' a , V : ' a , NodeRef : Deref < Target = Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
868
877
NodeType > {
869
878
// These are fine to include, but are currently unneeded.
870
879
//
@@ -883,8 +892,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
883
892
// }
884
893
}
885
894
886
- impl < ' a , K : ' a , V : ' a , NodeRef : DerefMut < Node < K , V > > + ' a , NodeType > Handle < NodeRef , handle:: KV ,
887
- NodeType > {
895
+ impl < ' a , K : ' a , V : ' a , NodeRef , NodeType > Handle < NodeRef , handle:: KV , NodeType > where
896
+ NodeRef : ' a + Deref < Target =Node < K , V > > + DerefMut ,
897
+ {
888
898
/// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
889
899
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
890
900
/// handle.
@@ -900,7 +910,9 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
900
910
}
901
911
}
902
912
903
- impl < K , V , NodeRef : DerefMut < Node < K , V > > , NodeType > Handle < NodeRef , handle:: KV , NodeType > {
913
+ impl < K , V , NodeRef , NodeType > Handle < NodeRef , handle:: KV , NodeType > where
914
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
915
+ {
904
916
/// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
905
917
/// to by this handle.
906
918
pub fn left_edge < ' a > ( & ' a mut self ) -> Handle < & ' a mut Node < K , V > , handle:: Edge , NodeType > {
@@ -920,7 +932,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV,
920
932
}
921
933
}
922
934
923
- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: KV , handle:: Leaf > {
935
+ impl < K , V , NodeRef > Handle < NodeRef , handle:: KV , handle:: Leaf > where
936
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut ,
937
+ {
924
938
/// Removes the key/value pair at the handle's location.
925
939
///
926
940
/// # Panics (in debug build)
@@ -931,7 +945,9 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Le
931
945
}
932
946
}
933
947
934
- impl < K , V , NodeRef : DerefMut < Node < K , V > > > Handle < NodeRef , handle:: KV , handle:: Internal > {
948
+ impl < K , V , NodeRef > Handle < NodeRef , handle:: KV , handle:: Internal > where
949
+ NodeRef : Deref < Target =Node < K , V > > + DerefMut
950
+ {
935
951
/// Steal! Stealing is roughly analogous to a binary tree rotation.
936
952
/// In this case, we're "rotating" right.
937
953
unsafe fn steal_rightward ( & mut self ) {
0 commit comments