diff --git a/src/graph.rs b/src/graph.rs index c0a7fd1..0b53391 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -15,9 +15,6 @@ use core::fmt::Debug; #[cfg(not(feature = "no_std"))] use std::fmt::Debug; -#[cfg(feature = "no_std")] -use core::mem; - #[cfg(feature = "no_std")] extern crate alloc; #[cfg(feature = "no_std")] @@ -89,8 +86,6 @@ pub struct Graph { edge_labels: HashMap, } -const DEFAULT_LABEL: &str = ""; - impl Graph { /// Creates a new graph. /// diff --git a/src/iterators/bfs.rs b/src/iterators/bfs.rs index 423ce3b..ffba428 100644 --- a/src/iterators/bfs.rs +++ b/src/iterators/bfs.rs @@ -56,8 +56,6 @@ impl<'a, T> Iterator for Bfs<'a, T> { fn next(&mut self) -> Option { loop { - let mut next_ptr = None; - if let Some(current_ptr) = &self.current_ptr { // Yield current pointed value if // it isn't in the visited stack. @@ -80,7 +78,7 @@ impl<'a, T> Iterator for Bfs<'a, T> { // Move to next root if possible and yield it. if self.queue.is_empty() { if let Some(next_root) = self.roots_stack.pop() { - next_ptr = Some(next_root); + self.current_ptr = Some(next_root); } else { // Break execution if there are no more roots return None; @@ -88,15 +86,11 @@ impl<'a, T> Iterator for Bfs<'a, T> { } else { // Pop item from queue and set it // as the current pointer. - next_ptr = self.queue.pop_front(); + self.current_ptr = self.queue.pop_front(); } } else { return None; } - - if next_ptr.is_some() { - self.current_ptr = next_ptr; - } } } } diff --git a/src/iterators/owning_iterator.rs b/src/iterators/owning_iterator.rs index 34bbcc3..0b40b89 100644 --- a/src/iterators/owning_iterator.rs +++ b/src/iterators/owning_iterator.rs @@ -2,12 +2,6 @@ use crate::vertex_id::VertexId; -#[cfg(feature = "no_std")] -extern crate alloc; - -#[cfg(feature = "no_std")] -use alloc::boxed::Box; - #[cfg(not(feature = "no_std"))] use std::fmt::Debug; diff --git a/src/iterators/topo.rs b/src/iterators/topo.rs index 29a4d00..442c499 100644 --- a/src/iterators/topo.rs +++ b/src/iterators/topo.rs @@ -72,7 +72,7 @@ impl<'a, T> Topo<'a, T> { } None => { if check_cyclic && self.vertices.len() != self.iterable.vertex_count() { - panic!(PANIC_MSG); + panic!("{}", PANIC_MSG); } None } diff --git a/src/lib.rs b/src/lib.rs index a6c241b..b28a70b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ // Copyright 2019 Octavian Oncescu -#![cfg_attr(feature = "no_std", feature(alloc))] #![cfg_attr(feature = "no_std", no_std)] //! # Graphlib