Skip to content

Commit

Permalink
Merge pull request #11 from sun-jacobi/push_front
Browse files Browse the repository at this point in the history
Add `List::push_front`
  • Loading branch information
RalfJung authored Jul 29, 2024
2 parents e85499a + 04bfc90 commit 1386718
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libspecr/src/list/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl<T: Obj> List<T> {
self.0.mutate(|v| v.pop_back())
}

/// Push an element to the beginning of the list.
pub fn push_front(&mut self, t: T) {
self.0.mutate(|v| v.push_front(t));
}

/// Pop the element from the beginning of the list.
/// Returns `None` is the list was empty.
pub fn pop_front(&mut self) -> Option<T> {
Expand Down

0 comments on commit 1386718

Please sign in to comment.