Skip to content

Instantly share code, notes, and snippets.

@freedomtowin
Created June 28, 2025 21:17
Show Gist options
  • Select an option

  • Save freedomtowin/ec1c0074b55dea1579398d746caf1101 to your computer and use it in GitHub Desktop.

Select an option

Save freedomtowin/ec1c0074b55dea1579398d746caf1101 to your computer and use it in GitHub Desktop.
Example of creating a Gist using Python
let mut log_time = false;
let mut log_ret = false;
// Create parser
let arg_parser = syn::meta::parser(|meta| {
if meta.path.is_ident("time") {
log_time = true;
Ok(())
} else if meta.path.is_ident("ret") {
log_ret = true;
Ok(())
} else {
// propagate errors
Err(meta.error("expected `time` or `ret`"))
}
});
let _ = parse_macro_input!(attr with arg_parser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment