aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--rust/src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index a96454e..213fa39 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -243,6 +243,17 @@ impl Value {
243 } 243 }
244 } 244 }
245 245
246 pub fn as_int( &self ) -> Result<i64,Error> {
247 if let Value::Integer(i) = self {
248 Ok(*i)
249 } else {
250 Err(Error::new(
251 ErrorKind::InvalidData,
252 "as_int called on non Integer value.",
253 ))
254 }
255 }
256
246 pub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error> { 257 pub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error> {
247 match self { 258 match self {
248 Self::Integer(x) => { 259 Self::Integer(x) => {