mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-14 21:23:08 +00:00
12 lines
244 B
Rust
12 lines
244 B
Rust
|
|
||
|
/// Generic trait to enable chainable API
|
||
|
pub trait With: Sized {
|
||
|
/// Calls the given closure on `self`.
|
||
|
fn with<F: FnOnce(&mut Self)>(mut self, f: F) -> Self {
|
||
|
f(&mut self);
|
||
|
self
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl <T: Sized> With for T {}
|