From a12fcbd24530b5192bd2badd7e5aebc4aab2fdd8 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 23 Mar 2024 09:03:06 -0700 Subject: [PATCH] docs: Add more documentation to push_or_else Signed-off-by: John Nunley --- src/bounded.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bounded.rs b/src/bounded.rs index d7c831e..72bcb03 100644 --- a/src/bounded.rs +++ b/src/bounded.rs @@ -136,6 +136,17 @@ impl Bounded { } /// 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(&self, mut value: T, mut fail: F) -> Result<(), PushError> where F: FnMut(T, usize, usize, &Slot) -> Result>,