Skip to content

Instantly share code, notes, and snippets.

@globin
Created October 26, 2014 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save globin/f7bd0f0b32ac8fd3b17c to your computer and use it in GitHub Desktop.
Save globin/f7bd0f0b32ac8fd3b17c to your computer and use it in GitHub Desktop.
struct_gen.rs
8:21: 8:33 error: cannot borrow immutable field as mutable
8 s_def.fields.push(Spanned {
^~~~~~~~~~~~
let mut strukt = (quote_item!(cx,
#[deriving(Show)]
struct $name;
)).unwrap();
strukt.map(|mut s| {
match s.node {
ItemStruct(ref mut s_def, _) => {
s_def.fields.push(Spanned {
node: StructField_ {
kind: NamedField(r.columns[0].name, Public),
id: ast::DUMMY_NODE_ID,
ty: quote_ty!(cx, uint),
attrs: vec![]
},
span: sp
})
}
_ => ()
};
s
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment