to_value

Function to_value 

Source
pub fn to_value<T>(value: &T) -> Result<Value, SerdeValueError>
where T: Serialize + ?Sized,
Expand description

Re-exports from the valu3 library for convenient access to value conversion traits.

ยงExamples

use quickleaf::prelude::*;

let mut cache = Quickleaf::new(10);

// ToValueBehavior trait is available from the prelude
cache.insert("number", 42);
cache.insert("string", "hello");
cache.insert("boolean", true);

assert_eq!(cache.get("number"), Some(&42.to_value()));
assert_eq!(cache.get("string"), Some(&"hello".to_value()));
assert_eq!(cache.get("boolean"), Some(&true.to_value()));

Serializa qualquer T: Serialize diretamente para Value sem passar por texto.