2016-07-16 20:25:21 +00:00
|
|
|
|
|
|
|
/// 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 {}
|