Trait Sleepsort

Source
pub trait Sleepsort: IntoIterator + Sized
where Self::Item: SleepsortItem + PartialOrd + Send + 'static,
{ // Provided methods fn sleepsort(self) -> SleepsortIter<Self::Item> { ... } fn sleepsort_with_speed( self, speed: SleepsortSpeed, ) -> SleepsortIter<Self::Item> { ... } }
Expand description

This trait provides the sleepsort functionality

Provided Methods§

Source

fn sleepsort(self) -> SleepsortIter<Self::Item>

Sleepsort is an unstable time-based variation of Countingsort that works by assigning every value to a thread and putting that thread to sleep for a time that is determined by that value:

for i in values:
    spawn a thread that sleeps i seconds
    output i

Unlike many other implementations, this one does not just print the values in order, but actually collects them, and is able to sort negative signed integers. Using it for other types is easily possible by simply implementing the SleepsortItem trait.

Source

fn sleepsort_with_speed( self, speed: SleepsortSpeed, ) -> SleepsortIter<Self::Item>

sleepsort with a custom speed. See SleepsortSpeed for more information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Sleepsort for T
where T: IntoIterator + Sized, T::Item: SleepsortItem + PartialOrd + Send + 'static,