Skip to main content
1 vote
0 answers
118 views

I have a proc macro where I'm generating code like quote! { pub mod #name { use super::some_sub_crate; // Do other stuff } } This means users of this proc macro must ensure ...
McBain's user avatar
  • 95
1 vote
1 answer
131 views

I have a workspace like this: . ├── main | └── ... (use those macros) └── macros └── ... (define my macros here) But by default I need to manually restart rust-analyzer every time I do changes ...
Yuki's user avatar
  • 73
11 votes
1 answer
184 views

I'm writing a derive proc-macro that automatically implements certain trait: trait Foo { fn go(&self); } Now given the following: #[derive(Foo)] struct ConcreteFoo; impl ConcreteFoo { ...
freakish's user avatar
  • 57.1k
0 votes
1 answer
68 views

I have this macro definition: //! Attribute macro to implement a discriminant method for enums with a specific representation type. use proc_macro::TokenStream; use proc_macro2::Span; use quote::...
user avatar
2 votes
1 answer
68 views

I am going to let the compiling error pointing to the expanded code but now it is only pointing to the outer line deriving the macro. What is the solution please? Thank you. proc macro: fn ...
Jiu hong's user avatar
  • 159
1 vote
0 answers
116 views

I'm trying to generate an enum type at compile-time, based on a json file. Following guides like https://developerlife.com/2022/03/30/rust-proc-macro/ I made this : An external crate my_macros since ...
MatthieuHAMEL's user avatar
3 votes
1 answer
316 views

I am trying to implement a trait Foo in a foo crate as well an identically named #[derive] proc-macro in an associated crate foo-macros. The intent is to have something like serde::Deserialize which ...
ereOn's user avatar
  • 56.5k
1 vote
0 answers
168 views

I'm trying to create a procedural macro to be applied on functions in my rust code. The macro implements logic to instrument and gather metrics on the applied method. I want to implement a metric ...
Julian Duru's user avatar
0 votes
0 answers
56 views

In my #[proc_macro_attribute] implementation of the custom attribute, I need to filter out the #[fix] attribute that may exist on an argument of a function. The custom function gets a input: ...
Yuri Astrakhan's user avatar
0 votes
1 answer
263 views

Currently, implementing a custom derive macro does not require an actual Trait to exist at all. All it does is to append an arbitrary code block after the annotated item, and apparently to remove the &...
Eugene Sh.'s user avatar
  • 18.7k
-1 votes
1 answer
76 views

I'm experimenting with proc-macro, the goal is that I can chain functions like a struct that contain fields of enums, Look at the test, the response will be permission::auth::moderator::execute::...
FatihAziz's user avatar
  • 453
0 votes
1 answer
189 views

Hello I'm creating a proc macro that I can use in my declarative macros that checks if 2 types are the same, and if so, it will select the first block, otherwise it should select the second block. ...
Yavor's user avatar
  • 73
0 votes
1 answer
180 views

I'm using quote to auto-generate code for use in an embedded system. Some of the auto-generated code has numbers which would be way easier to read as hex. Here's an example. use quote::quote; fn main(...
sciencectn's user avatar
  • 1,571
4 votes
1 answer
109 views

If I want to wrap a macro around offset_of!'s nested form, e.g. offset_of!(Foo, x.y.VariantA.0), what should x.y.VariantA.0 get parsed as in syn terms (e.g. which of these https://docs.rs/syn/latest/...
ajp's user avatar
  • 2,595
0 votes
1 answer
205 views

I use include_str!() to import the string from a file and pass it into a proc_marco, but it does not work. I get an expected string literal error. Here is my code: macro_rules! ptcl_layer { () =&...
yhw2003's user avatar
  • 17

15 30 50 per page
1
2 3 4 5
11