Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created June 30, 2014 09:28
Show Gist options
  • Save killerswan/b4e6d5840c46942bd3be to your computer and use it in GitHub Desktop.
Save killerswan/b4e6d5840c46942bd3be to your computer and use it in GitHub Desktop.
From ovid 84cec0e, trying to substitute $name instead of hard-coding it...
ovid $ git diff
diff --git a/CSVProvider.rs b/CSVProvider.rs
index ee8c7ba..b75d0ba 100644
--- a/CSVProvider.rs
+++ b/CSVProvider.rs
@@ -158,7 +158,7 @@ fn provide_csv_given_labels(cx: &mut ExtCtxt, sp: Span, tts: &[TokenT
fn define_my_csv(cx0: &mut ExtCtxt) -> Option<Gc<syntax::ast::Item>> {
let item1: Option<Gc<syntax::ast::Item>> = quote_item!(cx0,
- pub struct MyCSV {
+ pub struct $name {
pub data: Vec<(String)>,
}
);
ovid $
ovid $ ./build.sh
CSVProvider.rs:161:22: 161:26 error: can't capture dynamic environment in a fn item; use the || { ... } closure form instead
CSVProvider.rs:161 pub struct $name {
^~~~
note: in expansion of quote_item!
CSVProvider.rs:160:51: 164:9 note: expansion site
CSVProvider.rs:161:22: 161:26 error: unresolved name `name`.
CSVProvider.rs:161 pub struct $name {
^~~~
note: in expansion of quote_item!
CSVProvider.rs:160:51: 164:9 note: expansion site
error: aborting due to 2 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment