From b01cc81fea92813479e0485dc2de2b57622abe07 Mon Sep 17 00:00:00 2001 From: Jonah Lund Date: Mon, 9 Dec 2024 15:34:00 +0100 Subject: [PATCH] feat: `either` support --- Cargo.toml | 1 + core/Cargo.toml | 2 ++ core/src/lib.rs | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 0bdf552..df20ca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ rust-version = "1.70" [features] default = ["std"] std = ["vy-core/std"] +either = ["vy-core/either"] [dependencies] vy-macros = { version = "0.1.1", path = "macros" } diff --git a/core/Cargo.toml b/core/Cargo.toml index 8747579..33bfc78 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -9,9 +9,11 @@ license = "MIT" rust-version = "1.70" [dependencies] +either = { version = "1.13.0", optional = true } itoap = "1.0.1" ryu = "1.0.18" [features] default = ["std"] std = [] +either = ["dep:either"] diff --git a/core/src/lib.rs b/core/src/lib.rs index 1a7e2c3..1b1b9f2 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -124,6 +124,17 @@ impl ToHtml for [T; N] { } } +#[cfg(feature = "either")] +impl ToHtml for either::Either { + #[inline] + fn to_html(&self, buf: &mut String) { + match self { + either::Either::Left(left) => left.to_html(buf), + either::Either::Right(right) => right.to_html(buf), + } + } +} + macro_rules! impl_tuple { (( $($i:ident,)+