Skip to content

Commit

Permalink
feat: either support
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahlund committed Dec 9, 2024
1 parent e7aa97a commit b01cc81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
11 changes: 11 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ impl<T: ToHtml, const N: usize> ToHtml for [T; N] {
}
}

#[cfg(feature = "either")]
impl<A: ToHtml, B: ToHtml> ToHtml for either::Either<A, B> {
#[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,)+
Expand Down

0 comments on commit b01cc81

Please sign in to comment.