summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9dfe3cf..228699c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,22 +2,25 @@
//!
pub trait OptionInspect<F, T>
- where F: FnOnce(&T),
- T: Sized
+where
+ F: FnOnce(&T),
+ T: Sized,
{
fn inspect(self, f: F) -> Self;
}
pub trait OptionInspectRef<F, T>
- where F: FnOnce(&T),
- T: Sized
+where
+ F: FnOnce(&T),
+ T: Sized,
{
fn inspect(&self, f: F);
}
impl<F, T> OptionInspect<F, T> for Option<T>
- where F: FnOnce(&T),
- T: Sized
+where
+ F: FnOnce(&T),
+ T: Sized,
{
fn inspect(self, f: F) -> Self {
if let Some(ref o) = self.as_ref() {
@@ -29,8 +32,9 @@ impl<F, T> OptionInspect<F, T> for Option<T>
}
impl<F, T> OptionInspectRef<F, T> for Option<T>
- where F: FnOnce(&T),
- T: Sized
+where
+ F: FnOnce(&T),
+ T: Sized,
{
fn inspect(&self, f: F) {
if let Some(ref o) = self {
@@ -39,21 +43,23 @@ impl<F, T> OptionInspectRef<F, T> for Option<T>
}
}
-
pub trait OptionInspectNone<F>
- where F: FnOnce(),
+where
+ F: FnOnce(),
{
fn inspect_none(self, f: F) -> Self;
}
pub trait OptionInspectNoneRef<F>
- where F: FnOnce(),
+where
+ F: FnOnce(),
{
fn inspect_none(&self, f: F);
}
impl<F, T> OptionInspectNone<F> for Option<T>
- where F: FnOnce()
+where
+ F: FnOnce(),
{
fn inspect_none(self, f: F) -> Self {
if let None = self.as_ref() {
@@ -65,7 +71,8 @@ impl<F, T> OptionInspectNone<F> for Option<T>
}
impl<F, T> OptionInspectNoneRef<F> for Option<T>
- where F: FnOnce()
+where
+ F: FnOnce(),
{
fn inspect_none(&self, f: F) {
if let None = self {