Probably worth mentioning that its a good idea to write complex procedural macros with proc_macro2, because that allows the logic to be used outside of your macros, and allows for creating tests that are difficult to write otherwise.
Phew!!! That's a lot of stuff but the best explanation about the different types of macros so far... to be honest, I didn't know what to search for to get information about a term like "#[route(GET, "/")] because I didn't know how it is called 🤦♀ You videos a always a good starting point and most of the stuff is absolutely clear then... Thanks!!
F***Ing amazing! Best explanation for macros I've ever found! It had been complicated to find a clear explanation about this and it has been very helpful. Lots of thanks for your work! 🙌
Excellent video! I think it would be nice a video exploring different examples and problems that implement macros, specially attribute like macros and function like macros.
Ok these are unbelievably powerful. I thought the macro system would be worse than a language like c because theyre trying to make it safer. I definitely didnt expect to be able to define my own language inside them
Not sure if you had your question answered since posting this, but he basically says that "for complex technical reasons that the Rust team hopes to eliminate," you have to define it in it's own crate (at 1:04). At 3:40, he points back to 1:04, citing it as a reason for needing a separate crate for it. Idk if that classifies as an explanation, but if we take what he said at face value, then it seems like the need for a separate crate for the macro is the result of a side effect as opposed to an intended feature. tl;dr He says it's a workaround for a problem the rust team hopes to fix eventually (dk if anything changed in the year since this video was published).
Hello, I came from C++, and don't understand some things. Is using macros a good choice in Rust code? Are there some disadvantages? Should I first try to implement macro using basic macros, and only if that failed I should try to use procedural macros?
I have the same question! Writing macros in C++ are considered a bad thing, usually because of unreadable compiler errors & unmaintainability… The sql example looked like a very nice example which is probably not doable without macros, but does the rust (pre?)compiler gives readable errors?
@@DrumMeister After a little experience with Rust macros I can say some things I understood (not sure it is right). 1) There isn't any pre-processor idea in rust compiler. It's more complicated. 2) Rust can provide some usefull errors in macros, but you have to use right build options and etc. 3) Maintaining macros are also pretty hard, especially procedural. 4) I think, you should perefere macro_rules if your macro is very simple. If it's complicated you shoud better use procedural. Also macro_rules will be deprecated in future
Hey Bogdan! I think you're doing really great by making these videos for the rustaceans! But I do have a query about the std::io.. can you make a video about the inputs in rust.. to take different types inputs like int, long long, float, double etc.. It will be really great if this topic will be covered.. - New rustacean (rustling maybe)
I just hate how many implementation details of the one and only compiler leak so heavily into the language. It's just insane through how many hoops one has to jump.
These two videos are not very useful to learn macros, I can't say I've learned macros from these, please make a deep-dive playlist starting from the very basics and tame the complex ones.
📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
Yes, I would like to see more videos on macros. They are a very powerful tool
This series should be the official rust video tutorial. Very precise, concise and clear.
Probably worth mentioning that its a good idea to write complex procedural macros with proc_macro2, because that allows the logic to be used outside of your macros, and allows for creating tests that are difficult to write otherwise.
Phew!!! That's a lot of stuff but the best explanation about the different types of macros so far... to be honest, I didn't know what to search for to get information about a term like "#[route(GET, "/")] because I didn't know how it is called 🤦♀ You videos a always a good starting point and most of the stuff is absolutely clear then... Thanks!!
More videos about macros please
F***Ing amazing! Best explanation for macros I've ever found! It had been complicated to find a clear explanation about this and it has been very helpful. Lots of thanks for your work! 🙌
gettin into big boy stuff now 👌
Excellent video! I think it would be nice a video exploring different examples and problems that implement macros, specially attribute like macros and function like macros.
Ok these are unbelievably powerful. I thought the macro system would be worse than a language like c because theyre trying to make it safer. I definitely didnt expect to be able to define my own language inside them
It's a little complicated... Can you spend some time elaborating with possible examples
Here
ruclips.net/video/geovSK3wMB8/видео.html
This is a 4 hour long video on procedural Macros , and this is Part 1
Rust macros are powerful and neat from consumer perspective, on the other hand some of them makes code flow less obvious and code inspection harder.
This really helped me understand derive macros, thanks so much!
2:24 "We'll discuss why we'll need to bring two crates into scope in just a second"
Was this ever explained? Sorry if I had missed it.
Not sure if you had your question answered since posting this, but he basically says that "for complex technical reasons that the Rust team hopes to eliminate," you have to define it in it's own crate (at 1:04). At 3:40, he points back to 1:04, citing it as a reason for needing a separate crate for it. Idk if that classifies as an explanation, but if we take what he said at face value, then it seems like the need for a separate crate for the macro is the result of a side effect as opposed to an intended feature.
tl;dr He says it's a workaround for a problem the rust team hopes to fix eventually (dk if anything changed in the year since this video was published).
Great series I had ever seen please add some more Projects too that would be more helpful thanks
Need Macro series very badly buddy !!
Will make one eventually!
Yes! I would love to see more videos.
procedural macros for the gainzzz, buraaahh !!!
macros are hard to understand... honestly i still confuse and lost
How do I write a procedural macro which supports struct both with and without lifetime annotations?
Hello, I came from C++, and don't understand some things. Is using macros a good choice in Rust code? Are there some disadvantages? Should I first try to implement macro using basic macros, and only if that failed I should try to use procedural macros?
I have the same question! Writing macros in C++ are considered a bad thing, usually because of unreadable compiler errors & unmaintainability… The sql example looked like a very nice example which is probably not doable without macros, but does the rust (pre?)compiler gives readable errors?
@@DrumMeister After a little experience with Rust macros I can say some things I understood (not sure it is right).
1) There isn't any pre-processor idea in rust compiler. It's more complicated.
2) Rust can provide some usefull errors in macros, but you have to use right build options and etc.
3) Maintaining macros are also pretty hard, especially procedural.
4) I think, you should perefere macro_rules if your macro is very simple. If it's complicated you shoud better use procedural. Also macro_rules will be deprecated in future
How do you bring HelloMacro into scope 6:29? Should the derive crate have the macro on as dep?
Is that AOP for Rust? :D
How much time does it cost for you to produce 1 video every time? (preparation included)
Hey Bogdan! I think you're doing really great by making these videos for the rustaceans! But I do have a query about the std::io.. can you make a video about the inputs in rust.. to take different types inputs like int, long long, float, double etc.. It will be really great if this topic will be covered.. - New rustacean (rustling maybe)
It would help if you had realistic usecases. All of these macros should have been functions...
I'm glad this video exits.
More vids on macros!
I just hate how many implementation details of the one and only compiler leak so heavily into the language. It's just insane through how many hoops one has to jump.
Nice, macros we're some obscure to me yet and i Will be thansfull if You can show more abour
Rust is easy, yes I said Rust is easy
Moar macros
These two videos are not very useful to learn macros, I can't say I've learned macros from these, please make a deep-dive playlist starting from the very basics and tame the complex ones.
chishi
eh idk this seems too complicated for the general population of rustaceans
Looks like one of the sharp corners of rust. I really don't like the Syntax of this.