Struct uri_template_system_core::Values
source · 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)
9 10 11 12 13 14 15 16 17 18 19 20 21
fn main() -> Result<(), Box<dyn Error>> {
let template = Template::parse("/hello/{name}{/library*}")?;
let values = Values::default()
.add("name", Value::item("world"))
.add("library", Value::list(["uri", "template", "system"]));
assert_eq!(
template.expand(&values)?,
"/hello/world/uri/template/system"
);
Ok(())
}Trait Implementations§
source§impl PartialEq<Values> for Values
impl PartialEq<Values> for Values
impl Eq for Values
impl StructuralEq for Values
impl StructuralPartialEq for Values
Auto Trait Implementations§
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