pub trait Extract<T>: Sized {
// Required method
fn extract(from: Value<T>) -> Option<Self>;
}Expand description
A trait to denote types which can be extracted out of a Value<T>.
let value : Value<()> = Value::Integer(42);
assert_eq!(i64::extract(value), Some(42))For each accessibility kind there is an Option variant, treating a Value as a Option<T>, where
Value::Null denotes None and every other value is tried to get parsed into Some(t):
// any `Value::Null` is a `None`:
let value : Value<()> = Value::Null;
assert_eq!(<Option<String>>::extract(value), Some(None));
let value : Value<()> = Value::String(String::from("Hello World!"));
assert_eq!(<Option<String>>::extract(value), Some(Some(String::from("Hello World!"))));Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.