pub enum Either<A, B> {
Left(A),
Right(B),
}Expand description
Combines two different Presentables into a single type.
This is useful when conditionally choosing between two distinct
Presentable types:
ⓘ
use peace_fmt::{Either, Presentable};
let cond = true;
let presentable = if cond {
Either::Left(Bold::new(String::from("a")));
} else {
Either::Right(CodeInline::new("b".into()));
};
presentln!(output, &presentable);Variants§
Trait Implementations§
Source§impl<'de, A, B> Deserialize<'de> for Either<A, B>where
A: Deserialize<'de>,
B: Deserialize<'de>,
impl<'de, A, B> Deserialize<'de> for Either<A, B>where
A: Deserialize<'de>,
B: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<A, B> Presentable for Either<A, B>where
A: Presentable,
B: Presentable,
impl<A, B> Presentable for Either<A, B>where
A: Presentable,
B: Presentable,
Source§fn present<'output, 'life0, 'life1, 'async_trait, PR>(
&'life0 self,
presenter: &'life1 mut PR,
) -> Pin<Box<dyn Future<Output = Result<(), PR::Error>> + 'async_trait>>where
PR: Presenter<'output> + 'async_trait,
Self: 'async_trait,
'output: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn present<'output, 'life0, 'life1, 'async_trait, PR>(
&'life0 self,
presenter: &'life1 mut PR,
) -> Pin<Box<dyn Future<Output = Result<(), PR::Error>> + 'async_trait>>where
PR: Presenter<'output> + 'async_trait,
Self: 'async_trait,
'output: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Presents this data type to the user.
impl<A: Eq, B: Eq> Eq for Either<A, B>
impl<A, B> StructuralPartialEq for Either<A, B>
Auto Trait Implementations§
impl<A, B> Freeze for Either<A, B>
impl<A, B> RefUnwindSafe for Either<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Either<A, B>
impl<A, B> Sync for Either<A, B>
impl<A, B> Unpin for Either<A, B>
impl<A, B> UnwindSafe for Either<A, B>where
A: UnwindSafe,
B: UnwindSafe,
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