pub struct Budget { /* private fields */ }Expand description
A slice’s remaining allowance.
The contract is one call: Budget::spend returns false when the caller
should stop. It is not an error and it is not something to report. A
maintenance pass that runs out of budget has done part of its work and will
be back on the next turn, which is a hundred nanoseconds away.
Implementations§
Source§impl Budget
impl Budget
Sourcepub const fn standard() -> Budget
pub const fn standard() -> Budget
A budget of MAINTENANCE_UNITS.
Sourcepub const fn none() -> Budget
pub const fn none() -> Budget
A budget of nothing, which is what a turn hands to an engine that has asked not to be given a slice.
Sourcepub const fn spend(&mut self, units: u32) -> bool
pub const fn spend(&mut self, units: u32) -> bool
Charge units and say whether there is anything left to do after it.
The charge always goes through, even when it takes the budget past the end. Refusing it would mean the caller has to ask before every item and then do the item anyway, which is two branches for the same answer.
Trait Implementations§
impl Copy for Budget
impl Eq for Budget
impl StructuralPartialEq for Budget
Auto Trait Implementations§
impl Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more