mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-10 13:46:44 +01:00
constify and deinline some methods
This commit is contained in:
parent
4279503681
commit
18a01b8355
10 changed files with 124 additions and 92 deletions
|
|
@ -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| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue