Trait nvim_rs::rpc::unpack::TryUnpack[][src]

pub trait TryUnpack<V> {
    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

Returns the value contained in self.

Errors

Returns Err(self) if self does not contain a value of type V.

Implementors

This is needed because the blanket impl TryFrom<Value> for Value uses Error = !.

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.