#collection #queue #iterated #push #iter #remove #mutated

agenda

Safe collections that can be mutated while being iterated through

1 unstable release

Uses old Rust 2015

0.0.1 May 15, 2018

#41 in #iter

AGPL-3.0

15KB
142 lines

Agenda

Safe collections that can be mutated while being iterated through

This crate helps to improve the readability and remove some friction from worklist-style algorithms that might push to a collection while iterating through it.

License

AGPL3


lib.rs:

Convenient collection that allows safe mutation during iteration

Agenda offers queue-like functionality but has interior mutability to permit pushing and popping inside a for-loop.

use agenda::Queue;

fn iter(queue: Queue<String>) {
    for item in queue.iter() {
        match item.as_str() {
            "three" => queue.push(String::from("two")),
            "two" => queue.push(String::from("one")),
            "one" => queue.push(String::from("zero")),
            _ => {},
        }
    }
}

No runtime deps