mirror of
https://codeberg.org/icewind/php-literal-parser.git
synced 2026-06-03 10:34:08 +02:00
add as_int/float to Value
This commit is contained in:
parent
0090bea796
commit
2fac6f39e1
1 changed files with 16 additions and 0 deletions
16
src/lib.rs
16
src/lib.rs
|
|
@ -178,6 +178,22 @@ impl Value {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the value as i64 if it is an int
|
||||||
|
pub fn as_int(&self) -> Option<i64> {
|
||||||
|
match self {
|
||||||
|
Value::Int(int) => Some(*int),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the value as f64 if it is a float
|
||||||
|
pub fn as_float(&self) -> Option<f64> {
|
||||||
|
match self {
|
||||||
|
Value::Float(float) => Some(*float),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq<bool> for Value {
|
impl PartialEq<bool> for Value {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue