constify and deinline some methods

This commit is contained in:
🪞👃🪞 2025-04-13 21:11:07 +03:00
parent 4279503681
commit 18a01b8355
10 changed files with 124 additions and 92 deletions

View file

@ -2,11 +2,21 @@ use crate::*;
/// Show an item only when a condition is true.
pub struct When<A>(pub bool, pub A);
impl<A> When<A> { #[inline] pub fn new (c: bool, a: A) -> Self { Self(c, a) } }
impl<A> When<A> {
/// Create a binary condition.
pub const fn new (c: bool, a: A) -> Self {
Self(c, a)
}
}
/// Show one item if a condition is true and another if the condition is false
pub struct Either<A, B>(pub bool, pub A, pub B);
impl<A, B> Either<A, B> { #[inline] pub fn new (c: bool, a: A, b: B) -> Self { Self(c, a, b) } }
impl<A, B> Either<A, B> {
/// Create a ternary condition.
pub const fn new (c: bool, a: A, b: B) -> Self {
Self(c, a, b)
}
}
#[cfg(feature = "dsl")]
try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| {