pub struct Values { /* private fields */ }
Expand description
Implementations§
Source§impl Values
impl Values
Sourcepub fn add(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn add(self, key: impl Into<String>, value: impl Into<Value>) -> Self
Adds a new Value
to the Values
collection and returns the
modified collection to allow for chaining of calls during
construction. Values may be any type which implements Into<Value>
- this will generally be a concrete
Value
but may be your own type for which this trait has been implemented.
For clarity, it may be better to implement a suitable iterator trait for
your custom type and pass it to the relevant Value
construction
function, as this will make the shape of data produced more obvious for
anyone reading the code.
Examples found in repository?
examples/simple.rs (line 12)
9fn main() -> Result<(), Box<dyn Error>> {
10 let template = Template::parse("/hello/{name}{/library*}")?;
11 let values = Values::default()
12 .add("name", Value::item("world"))
13 .add("library", Value::list(["uri", "template", "system"]));
14
15 assert_eq!(
16 template.expand(&values)?,
17 "/hello/world/uri/template/system"
18 );
19
20 Ok(())
21}
Trait Implementations§
impl Eq for Values
impl StructuralPartialEq for Values
Auto Trait Implementations§
impl Freeze for Values
impl RefUnwindSafe for Values
impl Send for Values
impl Sync for Values
impl Unpin for Values
impl UnwindSafe for Values
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more