pub struct StreamMapAnyVariant(/* private fields */);
Expand description
Newtype around a Boxed Any.
Implementations§
Source§impl StreamMapAnyVariant
impl StreamMapAnyVariant
pub fn new<T>(value: T) -> Selfwhere
T: Any,
Sourcepub fn value<T>(self) -> Result<T, Self>where
T: Any,
pub fn value<T>(self) -> Result<T, Self>where
T: Any,
Retrieve the value if the type matches T.
If it doesn’t match, the variant will be returned as Err.
§Examples
use stream_map_any::StreamMapAnyVariant;
let variant = StreamMapAnyVariant::new(8u32);
let value = variant.value().unwrap();
assert_eq!(8u32, value);
// call will fail here because it has the wrong type.
let variant = StreamMapAnyVariant::new(8u32);
let value: Result<String, _> = variant.value();
assert!(value.is_err());
Sourcepub fn boxed_value<T>(self) -> Result<Box<T>, Self>where
T: Any,
pub fn boxed_value<T>(self) -> Result<Box<T>, Self>where
T: Any,
Retrieve a boxed value if the type matches T.
If it doesn’t match, the variant will be returned as Err.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamMapAnyVariant
impl !RefUnwindSafe for StreamMapAnyVariant
impl !Send for StreamMapAnyVariant
impl !Sync for StreamMapAnyVariant
impl Unpin for StreamMapAnyVariant
impl !UnwindSafe for StreamMapAnyVariant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more