mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-14 00:27:12 +00:00
split EitherOfX
into its own crate
This commit is contained in:
parent
3379462633
commit
ff51f064d4
3 changed files with 55 additions and 1 deletions
|
@ -7,6 +7,7 @@ members = [
|
|||
"next_tuple",
|
||||
"or_poisoned",
|
||||
"any_spawner",
|
||||
"either_of",
|
||||
|
||||
# core
|
||||
"hydration_context",
|
||||
|
@ -31,7 +32,7 @@ members = [
|
|||
|
||||
# libraries
|
||||
"meta",
|
||||
"router",
|
||||
"router", "either_of",
|
||||
]
|
||||
exclude = ["benchmarks", "examples"]
|
||||
|
||||
|
@ -42,6 +43,7 @@ rust-version = "1.75"
|
|||
[workspace.dependencies]
|
||||
any_spawner = { path = "./any_spawner/" }
|
||||
const_str_slice_concat = { path = "./const_str_slice_concat" }
|
||||
either_of = { path = "./either_of/" }
|
||||
hydration_context = { path = "./hydration_context" }
|
||||
leptos = { path = "./leptos", version = "0.6.5" }
|
||||
leptos_config = { path = "./leptos_config", version = "0.6.5" }
|
||||
|
|
8
either_of/Cargo.toml
Normal file
8
either_of/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "either_of"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
44
either_of/src/lib.rs
Normal file
44
either_of/src/lib.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
#![no_std]
|
||||
|
||||
use core::fmt::Display;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Either<A, B> {
|
||||
Left(A),
|
||||
Right(B),
|
||||
}
|
||||
|
||||
macro_rules! tuples {
|
||||
($name:ident => $($ty:ident),*) => {
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum $name<$($ty,)*> {
|
||||
$($ty ($ty),)*
|
||||
}
|
||||
|
||||
impl<$($ty,)*> Display for $name<$($ty,)*>
|
||||
where
|
||||
$($ty: Display,)*
|
||||
{
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
$($name::$ty(this) => this.fmt(f),)*
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tuples!(EitherOf3 => A, B, C);
|
||||
tuples!(EitherOf4 => A, B, C, D);
|
||||
tuples!(EitherOf5 => A, B, C, D, E);
|
||||
tuples!(EitherOf6 => A, B, C, D, E, F);
|
||||
tuples!(EitherOf7 => A, B, C, D, E, F, G);
|
||||
tuples!(EitherOf8 => A, B, C, D, E, F, G, H);
|
||||
tuples!(EitherOf9 => A, B, C, D, E, F, G, H, I);
|
||||
tuples!(EitherOf10 => A, B, C, D, E, F, G, H, I, J);
|
||||
tuples!(EitherOf11 => A, B, C, D, E, F, G, H, I, J, K);
|
||||
tuples!(EitherOf12 => A, B, C, D, E, F, G, H, I, J, K, L);
|
||||
tuples!(EitherOf13 => A, B, C, D, E, F, G, H, I, J, K, L, M);
|
||||
tuples!(EitherOf14 => A, B, C, D, E, F, G, H, I, J, K, L, M, N);
|
||||
tuples!(EitherOf15 => A, B, C, D, E, F, G, H, I, J, K, L, M, N, O);
|
||||
tuples!(EitherOf16 => A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P);
|
Loading…
Reference in a new issue