Trait nvim_rs::rpc::unpack::TryUnpack

source ·
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§

source

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§

source§

impl TryUnpack<(i64, i64)> for Value

source§

impl TryUnpack<Value> for Value

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

source§

impl TryUnpack<bool> for Value

source§

impl TryUnpack<i64> for Value

source§

impl TryUnpack<()> for Value

source§

impl TryUnpack<String> for Value

source§

impl TryUnpack<Vec<(Value, Value)>> for Value

source§

impl<T> TryUnpack<Vec<T>> for Value
where Value: TryUnpack<T> + From<T>,

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.