Skip to content

Commit

Permalink
get formatting back up to date with rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
iwburns committed May 17, 2018
1 parent 337a95e commit 92f4226
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 233 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl NodeIdError {
NodeIdError::InvalidNodeIdForTree => "The given NodeId belongs to a different Tree.",
NodeIdError::NodeIdNoLongerValid => {
"The given NodeId is no longer valid. The Node in question has been \
removed."
removed."
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/iterators.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::collections::VecDeque;
use std::slice::Iter;
use std::vec::IntoIter;
use std::collections::VecDeque;

use Tree;
use Node;
use NodeId;
use Tree;

///
/// An Iterator over the ancestors of a `Node`.
Expand Down Expand Up @@ -120,7 +120,9 @@ pub struct ChildrenIds<'a> {

impl<'a> ChildrenIds<'a> {
pub(crate) fn new<T>(tree: &'a Tree<T>, node_id: NodeId) -> ChildrenIds<'a> {
ChildrenIds { child_ids: tree.get_unsafe(&node_id).children().as_slice().iter() }
ChildrenIds {
child_ids: tree.get_unsafe(&node_id).children().as_slice().iter(),
}
}
}

Expand All @@ -145,7 +147,6 @@ pub struct PreOrderTraversal<'a, T: 'a> {

impl<'a, T> PreOrderTraversal<'a, T> {
pub(crate) fn new(tree: &'a Tree<T>, node_id: NodeId) -> PreOrderTraversal<T> {

// over allocating, but all at once instead of re-sizing and re-allocating as we go
let mut data = VecDeque::with_capacity(tree.nodes.capacity());

Expand Down Expand Up @@ -191,7 +192,6 @@ pub struct PostOrderTraversal<'a, T: 'a> {

impl<'a, T> PostOrderTraversal<'a, T> {
pub(crate) fn new(tree: &'a Tree<T>, node_id: NodeId) -> PostOrderTraversal<T> {

// over allocating, but all at once instead of re-sizing and re-allocating as we go
let mut ids = Vec::with_capacity(tree.nodes.capacity());

Expand Down Expand Up @@ -241,7 +241,6 @@ pub struct LevelOrderTraversal<'a, T: 'a> {

impl<'a, T> LevelOrderTraversal<'a, T> {
pub(crate) fn new(tree: &'a Tree<T>, node_id: NodeId) -> LevelOrderTraversal<T> {

// over allocating, but all at once instead of re-sizing and re-allocating as we go
let mut data = VecDeque::with_capacity(tree.nodes.capacity());

Expand All @@ -261,7 +260,6 @@ impl<'a, T> Iterator for LevelOrderTraversal<'a, T> {
let id = self.data.pop_front();

if let Some(ref node_id_ref) = id {

let node_ref = self.tree.get_unsafe(node_id_ref);

for child_id in node_ref.children() {
Expand All @@ -278,9 +276,9 @@ impl<'a, T> Iterator for LevelOrderTraversal<'a, T> {
#[cfg(test)]
mod tests {

use Tree;
use Node;
use InsertBehavior::*;
use Node;
use Tree;

#[test]
fn test_ancestors() {
Expand Down
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ mod iterators;
mod node;
mod tree;

pub use behaviors::RemoveBehavior;
pub use behaviors::MoveBehavior;
pub use behaviors::InsertBehavior;
pub use behaviors::MoveBehavior;
pub use behaviors::RemoveBehavior;
pub use behaviors::SwapBehavior;
pub use error::NodeIdError;
pub use node::NodeBuilder;
pub use node::Node;
pub use tree::TreeBuilder;
pub use tree::Tree;
pub use iterators::Ancestors;
pub use iterators::AncestorIds;
pub use iterators::Ancestors;
pub use iterators::Children;
pub use iterators::ChildrenIds;
pub use iterators::PreOrderTraversal;
pub use iterators::PostOrderTraversal;
pub use iterators::LevelOrderTraversal;
pub use iterators::PostOrderTraversal;
pub use iterators::PreOrderTraversal;
pub use node::Node;
pub use node::NodeBuilder;
pub use tree::Tree;
pub use tree::TreeBuilder;

///
/// An identifier used to differentiate between `Node`s within a `Tree`.
Expand Down
2 changes: 1 addition & 1 deletion src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ mod node_builder_tests {

#[cfg(test)]
mod node_tests {
use super::Node;
use super::super::NodeId;
use super::super::snowflake::ProcessUniqueId;
use super::Node;

#[test]
fn test_new() {
Expand Down
Loading

0 comments on commit 92f4226

Please sign in to comment.