use `either_of` crate
This commit is contained in:
parent
26869a78a0
commit
317f90e1e3
|
@ -6,6 +6,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
any_spawner = { workspace = true }
|
||||
const_str_slice_concat = { workspace = true }
|
||||
either_of = { workspace = true }
|
||||
next_tuple = { path = "../next_tuple" }
|
||||
reactive_graph = { workspace = true, optional = true }
|
||||
slotmap = { version = "1", optional = true }
|
||||
|
|
|
@ -3,11 +3,12 @@ use crate::{
|
|||
renderer::Renderer,
|
||||
ssr::StreamBuilder,
|
||||
view::{
|
||||
either::{Either, EitherState},
|
||||
Mountable, Position, PositionState, Render, RenderHtml,
|
||||
either::EitherState, Mountable, Position, PositionState, Render,
|
||||
RenderHtml,
|
||||
},
|
||||
};
|
||||
use any_spawner::Executor;
|
||||
use either_of::Either;
|
||||
use futures::FutureExt;
|
||||
use parking_lot::RwLock;
|
||||
use std::{fmt::Debug, future::Future, sync::Arc};
|
||||
|
|
|
@ -4,37 +4,12 @@ use crate::{
|
|||
renderer::{CastFrom, Renderer},
|
||||
ssr::StreamBuilder,
|
||||
};
|
||||
use either_of::*;
|
||||
use std::{
|
||||
error::Error,
|
||||
fmt::{Debug, Display},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Either<A, B> {
|
||||
Left(A),
|
||||
Right(B),
|
||||
}
|
||||
|
||||
impl<A, B> Display for Either<A, B>
|
||||
where
|
||||
A: Error,
|
||||
B: Error,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Either::Left(v) => std::fmt::Display::fmt(&v, f),
|
||||
Either::Right(v) => std::fmt::Display::fmt(&v, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> Error for Either<A, B>
|
||||
where
|
||||
A: Error,
|
||||
B: Error,
|
||||
{
|
||||
}
|
||||
|
||||
pub struct EitherState<A, B, Rndr>
|
||||
where
|
||||
A: Mountable<Rndr>,
|
||||
|
@ -215,28 +190,6 @@ const fn min_usize(vals: &[usize]) -> usize {
|
|||
macro_rules! tuples {
|
||||
($num:literal => $($ty:ident),*) => {
|
||||
paste::paste! {
|
||||
#[derive(Debug)]
|
||||
pub enum [<EitherOf $num>]<$($ty,)*> {
|
||||
$($ty ($ty),)*
|
||||
}
|
||||
|
||||
impl<$($ty,)*> Display for [<EitherOf $num>]<$($ty,)*>
|
||||
where
|
||||
$($ty: Display,)*
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
$([<EitherOf $num>]::$ty(this) => this.fmt(f),)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<$($ty,)*> Error for [<EitherOf $num>]<$($ty,)*>
|
||||
where
|
||||
$($ty: Error,)*
|
||||
{
|
||||
}
|
||||
|
||||
pub struct [<EitherOf $num State>]<$($ty,)* Rndr>
|
||||
where
|
||||
$($ty: Render<Rndr>,)*
|
||||
|
|
Loading…
Reference in New Issue