priority-set 0.1.0

A no_std Priority Set
Documentation
  • Coverage
  • 75%
    18 out of 24 items documented1 out of 16 items with examples
  • Size
  • Source code size: 32.94 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • afonso360/priority-set
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • afonso360

priority-set

A fixed size priority set suitable for no_std use.

Example:

#[derive(PartialEq)]
enum Command {
    QueryServerA,
    QueryServerB,
}

fn main() {
    // Create a priority set with 10 slots
    let mut p: PrioritySet<Command, 10> = PrioritySet::new();

    // Insert two items
    p.insert(Priority(10), Command::QueryServerA);
    p.insert(Priority(20), Command::QueryServerB);
    p.insert(Priority(30), Command::QueryServerA);
    
    // We inserted a duplicate command, so its priority was updated, but no new item was added
    assert_eq!(p.len(), 2);
    
    // Pops the highest priority item, which is QueryServerA with Priority(30)
    assert_eq!(p.pop(), Some(Command::QueryServerA));
    assert_eq!(p.pop(), Some(Command::QueryServerB));
    assert_eq!(p.pop(), None);
    
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.