forked from mirror/async-std
Use std::convert::identity
This commit is contained in:
parent
134089af2c
commit
38de0bfd22
4 changed files with 6 additions and 26 deletions
|
@ -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<T, V> FromStream<Option<T>> for Option<V>
|
||||
where
|
||||
|
@ -33,11 +33,7 @@ where
|
|||
.collect()
|
||||
.await;
|
||||
|
||||
if found_none {
|
||||
None
|
||||
} else {
|
||||
Some(out)
|
||||
}
|
||||
if found_none { None } else { Some(out) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<T, U> Product<Option<U>> for Option<T>
|
||||
where
|
||||
|
@ -57,11 +57,7 @@ where
|
|||
)
|
||||
.await;
|
||||
|
||||
if found_none {
|
||||
None
|
||||
} else {
|
||||
Some(out)
|
||||
}
|
||||
if found_none { None } else { Some(out) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<T, U> Sum<Option<U>> for Option<T>
|
||||
where
|
||||
|
@ -52,11 +52,7 @@ where
|
|||
)
|
||||
.await;
|
||||
|
||||
if found_none {
|
||||
None
|
||||
} else {
|
||||
Some(out)
|
||||
}
|
||||
if found_none { 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
|
||||
pub(crate) trait Context {
|
||||
fn context(self, message: impl Fn() -> String) -> Self;
|
||||
|
|
Loading…
Reference in a new issue