Skip to content

Commit

Permalink
TransIter: impl Default for Mode
Browse files Browse the repository at this point in the history
This will make switching the default mode easier, should we ever decide
to do so.
  • Loading branch information
neithernut committed Jun 20, 2021
1 parent 2f1c683 commit fef6bb7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<F: FnMut(&T) -> I, I: IntoIterator<Item = T>, T> TransIter<F, I, T> {
/// from the `initial` item through the given `recursion` function,
/// including the `initial` itself.
pub fn new(initial: T, recursion: F) -> Self {
Self {get_next: recursion, queue: std::iter::once(initial).collect(), mode: Mode::BreadthFirst}
Self {get_next: recursion, queue: std::iter::once(initial).collect(), mode: Default::default()}
}

/// Create a new transitive iterator with multiple initial items
Expand All @@ -71,7 +71,7 @@ impl<F: FnMut(&T) -> I, I: IntoIterator<Item = T>, T> TransIter<F, I, T> {
/// from the `initial` set of items through the given `recursion` function,
/// including the items in the initial set.
pub fn new_multi(initial: impl IntoIterator<Item = T>, recursion: F) -> Self {
Self {get_next: recursion, queue: FromIterator::from_iter(initial), mode: Mode::BreadthFirst}
Self {get_next: recursion, queue: FromIterator::from_iter(initial), mode: Default::default()}
}

/// Make this iterator iterate breadth first
Expand Down Expand Up @@ -143,6 +143,12 @@ enum Mode {
DepthFirstUnordered,
}

impl Default for Mode {
fn default() -> Self {
Self::BreadthFirst
}
}


/// Create a `TransIter` directly from some value
///
Expand Down

0 comments on commit fef6bb7

Please sign in to comment.