add as int method in Value

This commit is contained in:
bit-aloo
2025-07-30 09:31:00 +05:30
parent c8ba6a7d49
commit 24c260a05f

View File

@@ -329,6 +329,13 @@ impl Value {
}
}
pub fn as_int(&self) -> i64 {
match self {
Value::Integer(i) => *i,
_ => panic!("as_int must be called only for Value::Int"),
}
}
pub fn from_text(text: &str) -> Self {
Value::Text(Text::new(text))
}