summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/foundations/bool.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-10-27 19:04:55 +0100
committerGitHub <noreply@github.com>2024-10-27 18:04:55 +0000
commitbe7cfc85d08c545abfac08098b7b33b4bd71f37e (patch)
treef4137fa2aaa57babae1f7603a9b2ed7e688f43d8 /crates/typst-library/src/foundations/bool.rs
parentb8034a343831e8609aec2ec81eb7eeda57aa5d81 (diff)
Split out four new crates (#5302)
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(),
+ }
+ }
+}