pub fn Property<'a, 'x, T>(
name: &'a str,
variable: &'x mut T,
default: &'a T,
) -> Property<'a, 'x, T>Examples found in repository?
More examples
examples/nesting-techniques.rs (line 28)
26 fn visit(&mut self, f: &mut dyn FnMut(&mut dyn cvar::INode)) {
27 f(&mut cvar::Action("int", |args, writer| self.before_int_changed(args, writer)));
28 f(&mut cvar::Property("int", &mut self.int, &0));
29 f(&mut cvar::Property("float", &mut self.float, &0.0));
30 f(&mut cvar::Action("float", |args, writer| self.after_float_changed(args, writer)));
31 f(&mut cvar::Property("string", &mut self.string, &String::new()));
32 }
33}
34
35// Demonstrate how to create pseudo hierarchy allowing to inject nodes in a deeper nested namespace
36// It is not possible to inject a node in a parent, this would also clash with Rust's borrowing rules
37#[derive(Default)]
38struct Nested {
39 boolean: bool,
40 foo: Foo,
41}
42
43impl cvar::IVisit for Nested {
44 fn visit(&mut self, f: &mut dyn FnMut(&mut dyn cvar::INode)) {
45 f(&mut cvar::Property("foo.bool", &mut self.boolean, &false));
46 f(&mut cvar::List("foo", &mut self.foo));
47 }