Skip to content

Commit

Permalink
docs: Add more documentation to push_or_else
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Mar 23, 2024
1 parent 898ff46 commit a12fcbd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ impl<T> Bounded<T> {
}

/// Attempts to push an item into the queue, running a closure on failure.
///
/// `fail` is run when there is no more room left in the tail of the queue. The parameters of
/// this function are as follows:
///
/// - The item that failed to push.
/// - The value of `self.tail` before the new value would be inserted.
/// - The value of `self.tail` after the new value would be inserted.
/// - The slot that we attempted to push into.
///
/// If `fail` returns `Ok(val)`, we will try pushing `val` to the head of the queue. Otherwise,
/// this function will return the error.
fn push_or_else<F>(&self, mut value: T, mut fail: F) -> Result<(), PushError<T>>
where
F: FnMut(T, usize, usize, &Slot<T>) -> Result<T, PushError<T>>,
Expand Down

0 comments on commit a12fcbd

Please sign in to comment.