Use `std::convert::identity`

pull/667/head
Oleg Nosov 5 years ago
parent 134089af2c
commit 38de0bfd22
No known key found for this signature in database
GPG Key ID: DE90B83800644E24

@ -2,7 +2,7 @@ use std::pin::Pin;
use crate::prelude::*; use crate::prelude::*;
use crate::stream::{FromStream, IntoStream}; use crate::stream::{FromStream, IntoStream};
use crate::utils::identity; use std::convert::identity;
impl<T, V> FromStream<Option<T>> for Option<V> impl<T, V> FromStream<Option<T>> for Option<V>
where where
@ -33,11 +33,7 @@ where
.collect() .collect()
.await; .await;
if found_none { if found_none { None } else { Some(out) }
None
} else {
Some(out)
}
}) })
} }
} }

@ -2,7 +2,7 @@ use std::pin::Pin;
use crate::prelude::*; use crate::prelude::*;
use crate::stream::{Product, Stream}; use crate::stream::{Product, Stream};
use crate::utils::identity; use std::convert::identity;
impl<T, U> Product<Option<U>> for Option<T> impl<T, U> Product<Option<U>> for Option<T>
where where
@ -57,11 +57,7 @@ where
) )
.await; .await;
if found_none { if found_none { None } else { Some(out) }
None
} else {
Some(out)
}
}) })
} }
} }

@ -2,7 +2,7 @@ use std::pin::Pin;
use crate::prelude::*; use crate::prelude::*;
use crate::stream::{Stream, Sum}; use crate::stream::{Stream, Sum};
use crate::utils::identity; use std::convert::identity;
impl<T, U> Sum<Option<U>> for Option<T> impl<T, U> Sum<Option<U>> for Option<T>
where where
@ -52,11 +52,7 @@ where
) )
.await; .await;
if found_none { if found_none { None } else { Some(out) }
None
} else {
Some(out)
}
}) })
} }
} }

@ -52,14 +52,6 @@ pub fn random(n: u32) -> u32 {
}) })
} }
/// Returns given argument without changes.
#[allow(dead_code)]
#[doc(hidden)]
#[inline(always)]
pub(crate) fn identity<T>(arg: T) -> T {
arg
}
/// Add additional context to errors /// Add additional context to errors
pub(crate) trait Context { pub(crate) trait Context {
fn context(self, message: impl Fn() -> String) -> Self; fn context(self, message: impl Fn() -> String) -> Self;

Loading…
Cancel
Save