#ord #partial-ord #slice #iterator #float

no-std ord_subset

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

8 stable releases

Uses old Rust 2015

3.1.1 Sep 10, 2018
3.1.0 Nov 26, 2017
3.0.0 Oct 20, 2017
2.1.0 Sep 23, 2017
1.0.0 Aug 23, 2015

#995 in Rust patterns

Download history 1088/week @ 2023-12-06 834/week @ 2023-12-13 802/week @ 2023-12-20 784/week @ 2023-12-27 879/week @ 2024-01-03 1008/week @ 2024-01-10 970/week @ 2024-01-17 830/week @ 2024-01-24 704/week @ 2024-01-31 897/week @ 2024-02-07 1042/week @ 2024-02-14 961/week @ 2024-02-21 6708/week @ 2024-02-28 1344/week @ 2024-03-06 1173/week @ 2024-03-13 869/week @ 2024-03-20

10,331 downloads per month
Used in 20 crates (5 directly)

MIT/Apache

41KB
841 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

Features