Tracking issue for RFC 2351, "Add is_sorted to the standard library" (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@Centril

Description

@Centril

Feature gate: #![feature(is_sorted)]

This is a tracking issue for is_sorted{_by,_by_key} functions on [T] and Iterator (rust-lang/rfcs#2351).

Public API

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;

}

Steps / History

Unresolved Questions

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html