Skip to content

Commit

Permalink
update front
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello committed Mar 18, 2024
1 parent 192a825 commit 0094b72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,11 @@ impl Pointer {
}
self.inner[1..]
.split_once('/')
.map_or(Some((&self.inner[1..], "")), Option::Some)
.map(|(front, _)| Token::from_encoded(front))
.map_or_else(
|| Token::from_encoded(&self.inner[1..]),
|(front, _)| Token::from_encoded(front),
)
.into()
}
/// Returns the first `Token` in the `Pointer`.
///
Expand Down Expand Up @@ -1414,7 +1417,7 @@ mod tests {
assert_eq!(ptr.pop_front().unwrap().as_str(), *s);
}
assert_eq!(ptr.tokens().count(), 0);
assert!(ptr.back().is_none());
assert!(ptr.front().is_none());
assert!(ptr.pop_front().is_none());
}
}
Expand Down

0 comments on commit 0094b72

Please sign in to comment.