#iterator #slice #Ord #float #PartialOrd

ord_subset

Tools for working with the Ord subset of certain PartialOrd types, like floats

7 stable releases

3.1.0 Nov 26, 2017
3.0.0 Oct 20, 2017
2.1.0 Sep 23, 2017
2.0.0 Feb 28, 2017
1.0.0 Aug 23, 2015

#64 in Rust patterns

Download history 283/week @ 2018-08-19 320/week @ 2018-08-26 213/week @ 2018-09-02 212/week @ 2018-09-09 251/week @ 2018-09-16 387/week @ 2018-09-23 508/week @ 2018-09-30 297/week @ 2018-10-07 228/week @ 2018-10-14 333/week @ 2018-10-21 338/week @ 2018-10-28 350/week @ 2018-11-04 266/week @ 2018-11-11

713 downloads per month
Used in 5 crates (1 directly)

MIT/Apache

40KB
842 lines

ord_subset Build Status

Crate for working with the Ord subset of certain types like f32, f64.

Documentation is up at https://docs.rs/ord_subset/.

Usage

Add this to your Cargo.toml:

[dependencies]
ord_subset = "3"
extern crate ord_subset;
use ord_subset::{OrdSubsetIterExt, OrdSubsetSliceExt};

fn main() {
  // Slices. Works on vector, too.
  let mut s = [5.0, std::f64::NAN, 3.0, 2.0];
  s.ord_subset_sort();
  assert_eq!(&s[0..3], &[2.0, 3.0, 5.0]);
  assert_eq!(s.ord_subset_binary_search(&5.0), Ok(2));

  // iterators
  assert_eq!( s.iter().ord_subset_max(), Some(&5.0) );
  assert_eq!( s.iter().ord_subset_min(), Some(&2.0) );
}

License

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

No runtime deps