cursive/src/with.rs

11 lines
242 B
Rust
Raw Normal View History

/// 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
}
}
2016-07-16 20:52:28 +00:00
impl<T: Sized> With for T {}