summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/foundations/bool.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src/foundations/bool.rs')
-rw-r--r--crates/typst-library/src/foundations/bool.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/typst-library/src/foundations/bool.rs b/crates/typst-library/src/foundations/bool.rs
new file mode 100644
index 00000000..e88c8c6f
--- /dev/null
+++ b/crates/typst-library/src/foundations/bool.rs
@@ -0,0 +1,26 @@
+use ecow::EcoString;
+
+use crate::foundations::{ty, Repr};
+
+/// A type with two states.
+///
+/// The boolean type has two values: `{true}` and `{false}`. It denotes whether
+/// something is active or enabled.
+///
+/// # Example
+/// ```example
+/// #false \
+/// #true \
+/// #(1 < 2)
+/// ```
+#[ty(cast, title = "Boolean")]
+type bool;
+
+impl Repr for bool {
+ fn repr(&self) -> EcoString {
+ match self {
+ true => "true".into(),
+ false => "false".into(),
+ }
+ }
+}