summaryrefslogtreecommitdiffstats
path: root/src/visited.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-10-08 14:44:11 +0200
committerqkzk <qu3nt1n@gmail.com>2022-10-08 14:44:11 +0200
commite7d07026386e1636f3d524c2ed20467f82663cf4 (patch)
treeb8669eb654df15e408289f9696f17d2dbd2c6845 /src/visited.rs
parente9f9ee29e395a75a1ca7d7687b732f81238133d6 (diff)
visited
Diffstat (limited to 'src/visited.rs')
-rw-r--r--src/visited.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/visited.rs b/src/visited.rs
index c9b27bf..178bfe1 100644
--- a/src/visited.rs
+++ b/src/visited.rs
@@ -1,20 +1,11 @@
use std::path::PathBuf;
-#[derive(Clone, Debug)]
+#[derive(Default)]
pub struct History {
pub visited: Vec<PathBuf>,
pub index: usize,
}
-impl Default for History {
- fn default() -> Self {
- Self {
- visited: vec![],
- index: 0,
- }
- }
-}
-
impl History {
pub fn push(&mut self, path: &PathBuf) {
if !self.visited.contains(path) {
@@ -23,10 +14,6 @@ impl History {
}
}
- pub fn pop(&mut self) -> Option<PathBuf> {
- self.visited.pop()
- }
-
pub fn is_empty(&self) -> bool {
self.visited.is_empty()
}
@@ -62,6 +49,9 @@ impl History {
}
pub fn drop_queue(&mut self) {
+ if self.is_empty() {
+ return;
+ }
let final_length = self.len() - self.index;
self.visited.truncate(final_length);
if self.is_empty() {