pub trait TryUnpack<V> {
// Required method
fn try_unpack(self) -> Result<V, Value>;
}
Expand description
Trait to allow seamless conversion from a Value
to the type
it contains. In particular, this should never panic.
This is basically a specialized variant of TryInto<V> for Value
.
Required Methods§
sourcefn try_unpack(self) -> Result<V, Value>
fn try_unpack(self) -> Result<V, Value>
Returns the value contained in self
.
§Errors
Returns Err(self)
if self
does not contain a value of type V
.
Implementors§
impl TryUnpack<(i64, i64)> for Value
impl TryUnpack<Value> for Value
This is needed because the blanket impl TryFrom<Value> for Value
uses
Error = !
.
impl TryUnpack<bool> for Value
impl TryUnpack<i64> for Value
impl TryUnpack<()> for Value
impl TryUnpack<String> for Value
impl TryUnpack<Vec<(Value, Value)>> for Value
impl<T> TryUnpack<Vec<T>> for Value
The bound Value: From<T>
is necessary so we can recover the values if one
of the elements could not be unpacked. In practice, though, we only
implement TryUnpack<T>
in those cases anyways.