cursive/src/with.rs
Alexandre Bury 5b25893496 Rustfmt
2016-07-16 13:52:28 -07:00

12 lines
243 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 {}