From someone who was trying to get his head around quote, syn, and procedural macros for the first time, this was super helpful. Thank you! I have subscribed- keep the great content coming.
Great video! I am less scared to touch them now :) One question: I always assumed that the derive macro is used to autogenerate trait implementations. Here you inject the select directly into the Book struct implementation block. Is this common procedure, or just to keep it simple for a start?
What you do in such macros is completely up to you. There are also other popular macros which inject methods directly into the struct, so I wouldn't say it's an anti pattern. See also docs.rs/builder_macro/latest/builder_macro/
I think most of the time it is indeed more useful to generate them as a trait, as the macro is sorta acting like one (i.e. it always generates a function with the same name and signature in this case) and by implementing a trait you avoid potential name conflicts and allow users to write generic functions accepting anything that is selectable for example. The story for the builder_macro is different as it creates different function signatures for every struct it's invocated on, so it couldn't implement traits.
fantastic video, excellent explanations and editing. Because you obviously are a great coder I am thinking that you must have a pretty streamlined video editing process, and you picked your tools carefully. Could you share more about those? I need to put myself out there and learn by sharing videos, but the editing part is what bothers me most. How can you deliver such clean videos? Right now the only tools I have are obs studio and blender
Thanks so much for this nice comment! I use the program 'Shotcut' to edit my videos, it's open source and relatively easy to use. For screen recording I use the native macOS screen recorder, but you can also use OBS.
If I understand correctly, there is no need to match field.ident in get_entity_field function as we've already matched fields to be named, so simply .unwrapping that Option will be fine.
I love your fish/vim setup. Make a full tutorial on that? rustlang is the best! Hope it has this niche and small fanbase forever instead of becoming mainstream.
Als du deinen Namen gesagt hast war ich mir zu 100% sicher ich hätte auf ein deutsches Video geklickt. Ich war richtig schockiert als du auf einmal englisch geredet hast.
From someone who was trying to get his head around quote, syn, and procedural macros for the first time, this was super helpful. Thank you! I have subscribed- keep the great content coming.
Thank you! Glad I could help!
Wow, this is the exact problem I try to tackle for a long time! It will jumpstart my progress. Subbed!
You don't need to make a closure right 'filter_map(|field| get_entity_field(field))'? 'filter_map(get_entity_field)' should work?
Thank you, yes, that should also work!
This is exactly what I've been looking for. Great videos. You never miss. Thanks so much.
Thank you, Vladimir!
Great video! I am less scared to touch them now :)
One question: I always assumed that the derive macro is used to autogenerate trait implementations. Here you inject the select directly into the Book struct implementation block. Is this common procedure, or just to keep it simple for a start?
What you do in such macros is completely up to you. There are also other popular macros which inject methods directly into the struct, so I wouldn't say it's an anti pattern. See also docs.rs/builder_macro/latest/builder_macro/
I think most of the time it is indeed more useful to generate them as a trait, as the macro is sorta acting like one (i.e. it always generates a function with the same name and signature in this case) and by implementing a trait you avoid potential name conflicts and allow users to write generic functions accepting anything that is selectable for example.
The story for the builder_macro is different as it creates different function signatures for every struct it's invocated on, so it couldn't implement traits.
I’m still to wrap my head around all the things he blew by the explanation
I need more about macros
Great series!
Thanks a lot, NoPartiesGuy!
Thanks for the video! Is there any reason you used the match statement instead of the `?` operator?
Good question, to be honest I don't remember. Usually I strongly prefer `?` over match.
fantastic video, excellent explanations and editing. Because you obviously are a great coder I am thinking that you must have a pretty streamlined video editing process, and you picked your tools carefully. Could you share more about those? I need to put myself out there and learn by sharing videos, but the editing part is what bothers me most. How can you deliver such clean videos? Right now the only tools I have are obs studio and blender
Thanks so much for this nice comment! I use the program 'Shotcut' to edit my videos, it's open source and relatively easy to use. For screen recording I use the native macOS screen recorder, but you can also use OBS.
If I understand correctly, there is no need to match field.ident in get_entity_field function as we've already matched fields to be named, so simply .unwrapping that Option will be fine.
That's true, thanks for commenting!
Nice video.
Nice tutorial on the topic but the inlay hint is quite messy and is distracting.
Thanks for the feedback!
Nice tutorial. But please turn off the music completely next time because your explanations are more important than the music
Hi Haris, thanks! Yes, in all my newer videos I turned off the music completely.
I love your fish/vim setup. Make a full tutorial on that? rustlang is the best! Hope it has this niche and small fanbase forever instead of becoming mainstream.
Thank you! I did already make a tutorial on the vim setup: ua-cam.com/play/PLu-ydI-PCl0OEG0ZEqLRRuCrMJGAAI0tW.html
@@devonduty again. I love your videos man! I am subbed!
@@pinch-of-salt Thanks a lot!
Als du deinen Namen gesagt hast war ich mir zu 100% sicher ich hätte auf ein deutsches Video geklickt. Ich war richtig schockiert als du auf einmal englisch geredet hast.
:D
Liked the video, hated the Music