pub struct IoWriter<W>(pub W);Expand description
Io writer.
Helper which adapts to any std::io::Write objects such as stdout.
Tuple Fields§
§0: WImplementations§
Source§impl IoWriter<Stdout>
impl IoWriter<Stdout>
Sourcepub fn stdout() -> IoWriter<Stdout>
pub fn stdout() -> IoWriter<Stdout>
Examples found in repository?
examples/nesting-techniques.rs (line 69)
50fn main() {
51 let mut nested = Nested::default();
52
53 // This property appears nested but is set in the parent context
54 cvar::console::set_value(&mut nested, "foo.bool", &true, &mut cvar::NullWriter);
55 assert!(nested.boolean);
56
57 println!("Hit enter to list all the cvars and their values.");
58 println!("Assign value to cvar with `<name> <value>`.");
59
60 loop {
61 // Read input from stdin
62 let mut line = String::new();
63 if read_line(&mut line) {
64 break;
65 }
66
67 // Crude command line parsing
68 let (path, args) = split_line(&line);
69 cvar::console::poke(&mut nested, path, args, &mut cvar::IoWriter::stdout());
70 }
71}More examples
examples/runtime-properties.rs (line 93)
64fn main() {
65 let mut runtime_props = RuntimeProps::default();
66
67 // Create some runtime props
68 let mut writer = String::new();
69 cvar::console::invoke(&mut runtime_props, "create!", "float f 3.141592", &mut writer);
70 cvar::console::invoke(&mut runtime_props, "create!", "string s Hello World!", &mut writer);
71 cvar::console::invoke(&mut runtime_props, "create!", "int i 42", &mut writer);
72
73 // Inspect the underlying props
74 assert_eq!(runtime_props.props.len(), 3);
75 assert_eq!(runtime_props.props[0].get_value().to_string(), "3.141592");
76 assert_eq!(runtime_props.props[1].get_value().to_string(), "Hello World!");
77 assert_eq!(runtime_props.props[2].get_value().to_string(), "42");
78
79 println!("Hit enter to list all the cvars and their values.");
80 println!("Assign value to cvar with `<name> <value>`.");
81 println!("Create new cvars with `create! <type> <name> <value>`.");
82 println!("Destroy the cvars with `destroy! <name>.");
83
84 loop {
85 // Read input from stdin
86 let mut line = String::new();
87 if read_line(&mut line) {
88 break;
89 }
90
91 // Crude command line parsing
92 let (path, args) = split_line(&line);
93 cvar::console::poke(&mut runtime_props, path, args, &mut cvar::IoWriter::stdout());
94 }
95}Trait Implementations§
Source§impl<W: Write> Write for IoWriter<W>
impl<W: Write> Write for IoWriter<W>
impl<W: Write + 'static> IWrite for IoWriter<W>
Auto Trait Implementations§
impl<W> Freeze for IoWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for IoWriter<W>where
W: RefUnwindSafe,
impl<W> Send for IoWriter<W>where
W: Send,
impl<W> Sync for IoWriter<W>where
W: Sync,
impl<W> Unpin for IoWriter<W>where
W: Unpin,
impl<W> UnwindSafe for IoWriter<W>where
W: UnwindSafe,
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