diff --git a/implementations/rust/preserves/src/value/repr.rs b/implementations/rust/preserves/src/value/repr.rs index f703436..b72aa71 100644 --- a/implementations/rust/preserves/src/value/repr.rs +++ b/implementations/rust/preserves/src/value/repr.rs @@ -734,6 +734,14 @@ impl Value { } } + #[inline(always)] + pub fn into_string(self) -> Option { + match self { + Value::String(s) => Some(s), + _ => None, + } + } + #[inline(always)] pub fn to_string(&self) -> Result<&String, Error> { self.as_string().ok_or_else(|| self.expected(ExpectedKind::String)) @@ -767,6 +775,14 @@ impl Value { } } + #[inline(always)] + pub fn into_bytestring(self) -> Option> { + match self { + Value::ByteString(bs) => Some(bs), + _ => None, + } + } + #[inline(always)] pub fn to_bytestring(&self) -> Result<&Vec, Error> { self.as_bytestring().ok_or_else(|| self.expected(ExpectedKind::ByteString)) @@ -800,6 +816,14 @@ impl Value { } } + #[inline(always)] + pub fn into_symbol(self) -> Option { + match self { + Value::Symbol(s) => Some(s), + _ => None, + } + } + #[inline(always)] pub fn to_symbol(&self) -> Result<&String, Error> { self.as_symbol().ok_or_else(|| self.expected(ExpectedKind::Symbol))