Skip to content

Commit

Permalink
simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Mar 18, 2024
1 parent 0094b72 commit dcb50f9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,19 @@ impl Pointer {
}
/// Removes and returns the first `Token` in the `Pointer` if it exists.
pub fn pop_front(&mut self) -> Option<Token> {
if !self.inner.is_empty() && self.count > 0 {
(!self.inner.is_empty() && self.count > 0).then(|| {
self.count -= 1;

if let Some((front, back)) = self.inner[1..].split_once('/') {
let front = Token::from_encoded(front);
self.inner = String::from("/") + back;
Some(front)
front
} else {
let token = Token::from_encoded(&self.inner[1..]);
self.inner.truncate(0);
Some(token)
token
}
} else {
None
}
})
}
/// Returns the number of tokens in the `Pointer`.
pub fn count(&self) -> usize {
Expand Down

0 comments on commit dcb50f9

Please sign in to comment.