pub struct VecWriter { /* private fields */ }
Expand description
Helper struct to format a token stream as a vector of strings.
Examples
use genco::prelude::*;
use genco::fmt;
let map = rust::import("std::collections", "HashMap");
let tokens: rust::Tokens = quote! {
let mut m = $map::new();
m.insert(1u32, 2u32);
};
// Note: String implements std::fmt::Write
let mut w = fmt::VecWriter::new();
let fmt = fmt::Config::from_lang::<Rust>();
let config = rust::Config::default();
// Default format state for Rust.
let format = rust::Format::default();
tokens.format(&mut w.as_formatter(&fmt), &config, &format)?;
let vec = w.into_vec();
assert_eq!(
vec![
"let mut m = HashMap::new();",
"m.insert(1u32, 2u32);",
],
vec
);
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for VecWriter
impl Send for VecWriter
impl Sync for VecWriter
impl Unpin for VecWriter
impl UnwindSafe for VecWriter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more