-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document budgeting and limiting (#637)
- Loading branch information
Showing
16 changed files
with
241 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! A trait used for types which can be called. | ||
//! | ||
//! This trait allows for memory [`limits`] and [`budgets`] to be combined. | ||
//! | ||
//! [`limits`]: crate::limit | ||
//! [`budgets`]: ../../runtime/budget/index.html | ||
/// A trait used for types which can be called. | ||
/// | ||
/// This trait allows for memory [`limits`] and [`budgets`] to be combined. | ||
/// | ||
/// [`limits`]: crate::limit | ||
/// [`budgets`]: ../../runtime/budget/index.html | ||
pub trait Callable { | ||
/// Output of the callable. | ||
type Output; | ||
|
||
/// Call and consume the callable. | ||
fn call(self) -> Self::Output; | ||
} | ||
|
||
/// Blanket implementation for closures. | ||
impl<T, O> Callable for T | ||
where | ||
T: FnOnce() -> O, | ||
{ | ||
type Output = O; | ||
|
||
fn call(self) -> Self::Output { | ||
self() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.