diff options
| author | djzin <noreply@github.com> | 2016-12-24 16:17:22 +0000 |
|---|---|---|
| committer | djzin <noreply@github.com> | 2017-01-14 16:51:51 +0000 |
| commit | 14b0ea8aa6886ef831b2e8074c5bbd7b36cc5679 (patch) | |
| tree | 9cd184c705e5779c227b585b4dcfb9ef151e9ec6 /src/libcollections | |
| parent | c72605ac6273720f768753365e2c53249943af3e (diff) | |
| download | rust-14b0ea8aa6886ef831b2e8074c5bbd7b36cc5679.tar.gz rust-14b0ea8aa6886ef831b2e8074c5bbd7b36cc5679.zip | |
fix up tests
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/btree/map.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/btree/set.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/range.rs | 22 |
3 files changed, 17 insertions, 13 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index e588c99d169..544053096fe 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -674,10 +674,10 @@ impl<K: Ord, V> BTreeMap<K, V> { /// map.insert(3, "a"); /// map.insert(5, "b"); /// map.insert(8, "c"); - /// for (&key, &value) in map.range(Included(&4), Included(&8)) { + /// for (&key, &value) in map.range((Included(&4), Included(&8))) { /// println!("{}: {}", key, value); /// } - /// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next()); + /// assert_eq!(Some((&5, &"b")), map.range((Included(&4), Unbounded)).next()); /// ``` #[unstable(feature = "btree_range", reason = "matches collection reform specification, waiting for dust to settle", diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index f941b40dcf7..a63e2e6765e 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -224,10 +224,10 @@ impl<T: Ord> BTreeSet<T> { /// set.insert(3); /// set.insert(5); /// set.insert(8); - /// for &elem in set.range(Included(&4), Included(&8)) { + /// for &elem in set.range((Included(&4), Included(&8))) { /// println!("{}", elem); /// } - /// assert_eq!(Some(&5), set.range(Included(&4), Unbounded).next()); + /// assert_eq!(Some(&5), set.range((Included(&4), Unbounded)).next()); /// ``` #[unstable(feature = "btree_range", reason = "matches collection reform specification, waiting for dust to settle", diff --git a/src/libcollections/range.rs b/src/libcollections/range.rs index 92716538147..0326b92203a 100644 --- a/src/libcollections/range.rs +++ b/src/libcollections/range.rs @@ -19,47 +19,51 @@ use Bound::{self, Excluded, Included, Unbounded}; /// **RangeArgument** is implemented by Rust's built-in range types, produced /// by range syntax like `..`, `a..`, `..b` or `c..d`. -pub trait RangeArgument<T> { - /// Start index (inclusive) +pub trait RangeArgument<T: ?Sized> { + /// Start index bound /// - /// Return start value if present, else `None`. + /// Return start value as a `Bound` /// /// # Examples /// /// ``` /// #![feature(collections)] /// #![feature(collections_range)] + /// #![feature(collections_bound)] /// /// extern crate collections; /// /// # fn main() { /// use collections::range::RangeArgument; + /// use collections::Bound::*; /// - /// assert_eq!((..10).start(), None); - /// assert_eq!((3..10).start(), Some(&3)); + /// assert_eq!((..10).start(), Unbounded); + /// assert_eq!((3..10).start(), Included(&3)); /// # } /// ``` fn start(&self) -> Bound<&T> { Unbounded } - /// End index (exclusive) + /// End index bound /// - /// Return end value if present, else `None`. + /// Return end value as a `Bound` /// /// # Examples /// /// ``` /// #![feature(collections)] /// #![feature(collections_range)] + /// #![feature(collections_bound)] /// /// extern crate collections; /// /// # fn main() { /// use collections::range::RangeArgument; + /// use collections::Bound::*; /// - /// assert_eq!((3..).end(), None); - /// assert_eq!((3..10).end(), Some(&10)); + /// assert_eq!((3..).end(), Unbounded); + /// assert_eq!((3..10).end(), Excluded(&10)); /// # } /// ``` fn end(&self) -> Bound<&T> { |
