projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8fcf023
)
rust: Introduce Datum::is_string, Datum::is_number.
author
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 25 Aug 2025 02:30:28 +0000
(19:30 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 25 Aug 2025 02:30:28 +0000
(19:30 -0700)
rust/pspp/src/data.rs
patch
|
blob
|
history
diff --git
a/rust/pspp/src/data.rs
b/rust/pspp/src/data.rs
index fa47025756f7d698711f273fbcd4ba56ac371bcb..0fb311cf5f100c1efd961adaab6844c6aced3931 100644
(file)
--- a/
rust/pspp/src/data.rs
+++ b/
rust/pspp/src/data.rs
@@
-561,6
+561,14
@@
impl<B> Datum<B> {
matches!(self, Self::Number(None))
}
+ pub const fn is_number(&self) -> bool {
+ matches!(self, Self::Number(_))
+ }
+
+ pub const fn is_string(&self) -> bool {
+ matches!(self, Self::String(_))
+ }
+
/// Returns the number inside this datum, or `None` if this is a string
/// datum.
pub fn as_number(&self) -> Option<Option<f64>> {