cursive/src/with.rs
Alexandre Bury e4cd68a4eb Rustfmt
2017-12-30 23:03:42 +01:00

11 lines
242 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 {}