typst_library/foundations/
bool.rs

1use ecow::EcoString;
2
3use crate::foundations::{Repr, ty};
4
5/// A type with two states.
6///
7/// The boolean type has two values: `{true}` and `{false}`. It denotes whether
8/// something is active or enabled.
9///
10/// # Example
11/// ```example
12/// #false \
13/// #true \
14/// #(1 < 2)
15/// ```
16#[ty(cast, title = "Boolean")]
17type bool;
18
19impl Repr for bool {
20    fn repr(&self) -> EcoString {
21        match self {
22            true => "true".into(),
23            false => "false".into(),
24        }
25    }
26}