Tracking issue for RFC 2351, "Add is_sorted
to the standard library" · Issue #53485 · rust-lang/rust (original) (raw)
This is a tracking issue for is_sorted{_by,_by_key}
functions on [T]
and Iterator
(rust-lang/rfcs#2351).
impl [T] { pub fn is_sorted(&self) -> bool where T: PartialOrd;
pub fn is_sorted_by<'a, F>(&'a self, mut compare: F) -> bool
where
F: FnMut(&'a T, &'a T) -> bool;
pub fn is_sorted_by_key<'a, F, K>(&'a self, f: F) -> bool
where
F: FnMut(&'a T) -> K,
K: PartialOrd;
}
// core::iter
pub trait Iterator { // all the other methods omitted
fn is_sorted(self) -> bool
where
Self: Sized,
Self::Item: PartialOrd;
fn is_sorted_by<F>(mut self, compare: F) -> bool
where
Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> bool;
fn is_sorted_by_key<F, K>(self, f: F) -> bool
where
Self: Sized,
F: FnMut(Self::Item) -> K,
K: PartialOrd;
}