From 38de0bfd2267cb299952046f129eb6cc896bde9a Mon Sep 17 00:00:00 2001 From: Oleg Nosov Date: Wed, 15 Jan 2020 09:42:30 +0300 Subject: [PATCH] Use `std::convert::identity` --- src/option/from_stream.rs | 8 ++------ src/option/product.rs | 8 ++------ src/option/sum.rs | 8 ++------ src/utils.rs | 8 -------- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/option/from_stream.rs b/src/option/from_stream.rs index 2194f294..de929ca9 100644 --- a/src/option/from_stream.rs +++ b/src/option/from_stream.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use crate::prelude::*; use crate::stream::{FromStream, IntoStream}; -use crate::utils::identity; +use std::convert::identity; impl FromStream> for Option where @@ -33,11 +33,7 @@ where .collect() .await; - if found_none { - None - } else { - Some(out) - } + if found_none { None } else { Some(out) } }) } } diff --git a/src/option/product.rs b/src/option/product.rs index f733befc..b446c1ff 100644 --- a/src/option/product.rs +++ b/src/option/product.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use crate::prelude::*; use crate::stream::{Product, Stream}; -use crate::utils::identity; +use std::convert::identity; impl Product> for Option where @@ -57,11 +57,7 @@ where ) .await; - if found_none { - None - } else { - Some(out) - } + if found_none { None } else { Some(out) } }) } } diff --git a/src/option/sum.rs b/src/option/sum.rs index 64fdb073..de404f42 100644 --- a/src/option/sum.rs +++ b/src/option/sum.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use crate::prelude::*; use crate::stream::{Stream, Sum}; -use crate::utils::identity; +use std::convert::identity; impl Sum> for Option where @@ -52,11 +52,7 @@ where ) .await; - if found_none { - None - } else { - Some(out) - } + if found_none { None } else { Some(out) } }) } } diff --git a/src/utils.rs b/src/utils.rs index 780e733a..ef50ed02 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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(arg: T) -> T { - arg -} - /// Add additional context to errors pub(crate) trait Context { fn context(self, message: impl Fn() -> String) -> Self;