]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #16031 : arielb1/rust/remove_unneeded_fixme, r=kballard
authorbors <bors@rust-lang.org>
Sun, 27 Jul 2014 22:41:15 +0000 (22:41 +0000)
committerbors <bors@rust-lang.org>
Sun, 27 Jul 2014 22:41:15 +0000 (22:41 +0000)
The issue was fixed a month ago - remove the workaround.

src/doc/guide-container.md
src/libcollections/ringbuf.rs
src/libstd/collections/hashmap.rs

index 3fe237b1748adac80b85522fd6bc85a31d95065c..1733f4934c0c298efa92922b383a03cb05aadc51 100644 (file)
@@ -118,7 +118,7 @@ differently.
 ## Container iterators
 
 Containers implement iteration over the contained elements by returning an
-iterator object. For example, vector slices several iterators available:
+iterator object. For example, for vector slices several iterators are available:
 
 * `iter()` for immutable references to the elements
 * `mut_iter()` for mutable references to the elements
index dcb8628c5a64840cee91ee2d6a4385b09473f566..44b546f665688a069ca478a4f1198cf06ab643b7 100644 (file)
@@ -19,6 +19,8 @@
 use core::default::Default;
 use core::fmt;
 use core::iter::RandomAccessIterator;
+use core::iter;
+use std::hash::{Writer, Hash};
 
 use {Deque, Collection, Mutable, MutableSeq};
 use vec::Vec;
@@ -450,6 +452,21 @@ fn ne(&self, other: &RingBuf<A>) -> bool {
     }
 }
 
+impl<A: PartialOrd> PartialOrd for RingBuf<A> {
+    fn partial_cmp(&self, other: &RingBuf<A>) -> Option<Ordering> {
+        iter::order::partial_cmp(self.iter(), other.iter())
+    }
+}
+
+impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
+    fn hash(&self, state: &mut S) {
+        self.len().hash(state);
+        for elt in self.iter() {
+            elt.hash(state);
+        }
+    }
+}
+
 impl<A> FromIterator<A> for RingBuf<A> {
     fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
         let (lower, _) = iterator.size_hint();
@@ -485,6 +502,7 @@ mod tests {
     use std::fmt::Show;
     use std::prelude::*;
     use std::gc::{GC, Gc};
+    use std::hash;
     use test::Bencher;
     use test;
 
@@ -912,6 +930,37 @@ fn test_eq() {
         assert!(e == RingBuf::new());
     }
 
+    #[test]
+    fn test_hash() {
+      let mut x = RingBuf::new();
+      let mut y = RingBuf::new();
+
+      x.push(1i);
+      x.push(2);
+      x.push(3);
+
+      y.push(0i);
+      y.push(1i);
+      y.pop_front();
+      y.push(2);
+      y.push(3);
+
+      assert!(hash::hash(&x) == hash::hash(&y));
+    }
+
+    #[test]
+    fn test_ord() {
+        let x = RingBuf::new();
+        let mut y = RingBuf::new();
+        y.push(1i);
+        y.push(2);
+        y.push(3);
+        assert!(x < y);
+        assert!(y > x);
+        assert!(x <= x);
+        assert!(x >= x);
+    }
+
     #[test]
     fn test_show() {
         let ringbuf: RingBuf<int> = range(0i, 10).collect();
index e825dc3a8b5fd2a95d66e8e4cc955d885059aa4e..8b6e6d61842ae965c2971251bd537d74b53db949 100644 (file)
@@ -1850,6 +1850,7 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
     ///
     /// # Example
     ///
+    /// ```
     /// use std::collections::HashSet;
     /// let mut set: HashSet<int> = HashSet::new();
     /// ```
@@ -1863,6 +1864,7 @@ pub fn new() -> HashSet<T, RandomSipHasher> {
     ///
     /// # Example
     ///
+    /// ```
     /// use std::collections::HashSet;
     /// let mut set: HashSet<int> = HashSet::with_capacity(10);
     /// ```
@@ -1920,6 +1922,7 @@ pub fn with_capacity_and_hasher(capacity: uint, hasher: H) -> HashSet<T, H> {
     ///
     /// # Example
     ///
+    /// ```
     /// use std::collections::HashSet;
     /// let mut set: HashSet<int> = HashSet::new();
     /// set.reserve(10);