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::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…
Reference in a new issue