change argument for btree_range
This commit is contained in:
parent
3711d2f902
commit
18f1b1fce4
2 changed files with 9 additions and 12 deletions
|
@ -18,6 +18,7 @@ use core::{fmt, intrinsics, mem, ptr};
|
|||
|
||||
use borrow::Borrow;
|
||||
use Bound::{self, Excluded, Included, Unbounded};
|
||||
use range::RangeArgument;
|
||||
|
||||
use super::node::{self, Handle, NodeRef, marker};
|
||||
use super::search;
|
||||
|
@ -681,12 +682,11 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
|||
#[unstable(feature = "btree_range",
|
||||
reason = "matches collection reform specification, waiting for dust to settle",
|
||||
issue = "27787")]
|
||||
pub fn range<Min: ?Sized + Ord, Max: ?Sized + Ord>(&self,
|
||||
min: Bound<&Min>,
|
||||
max: Bound<&Max>)
|
||||
-> Range<K, V>
|
||||
where K: Borrow<Min> + Borrow<Max>
|
||||
pub fn range<T: ?Sized, R>(&self, range: R) -> Range<K, V>
|
||||
where T: Ord, K: Borrow<T>, R: RangeArgument<T>
|
||||
{
|
||||
let min = range.start();
|
||||
let max = range.end();
|
||||
let front = match min {
|
||||
Included(key) => {
|
||||
match search::search_tree(self.root.as_ref(), key) {
|
||||
|
|
|
@ -21,7 +21,7 @@ use core::ops::{BitOr, BitAnd, BitXor, Sub};
|
|||
use borrow::Borrow;
|
||||
use btree_map::{BTreeMap, Keys};
|
||||
use super::Recover;
|
||||
use Bound;
|
||||
use range::RangeArgument;
|
||||
|
||||
// FIXME(conventions): implement bounded iterators
|
||||
|
||||
|
@ -232,13 +232,10 @@ impl<T: Ord> BTreeSet<T> {
|
|||
#[unstable(feature = "btree_range",
|
||||
reason = "matches collection reform specification, waiting for dust to settle",
|
||||
issue = "27787")]
|
||||
pub fn range<'a, Min: ?Sized + Ord, Max: ?Sized + Ord>(&'a self,
|
||||
min: Bound<&Min>,
|
||||
max: Bound<&Max>)
|
||||
-> Range<'a, T>
|
||||
where T: Borrow<Min> + Borrow<Max>
|
||||
pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T>
|
||||
where K: Ord, T: Borrow<K>, R: RangeArgument<K>
|
||||
{
|
||||
Range { iter: self.map.range(min, max) }
|
||||
Range { iter: self.map.range(range) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue