Procedural Macros in Rust

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 43

  • @letsgetrusty
    @letsgetrusty  3 года назад +5

    📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet

  • @magnoelmagnifico957
    @magnoelmagnifico957 3 года назад +58

    Yes, I would like to see more videos on macros. They are a very powerful tool

  • @evidgamer1699
    @evidgamer1699 3 года назад +26

    This series should be the official rust video tutorial. Very precise, concise and clear.

  • @tserica
    @tserica Год назад +4

    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.

  • @dimiutube
    @dimiutube 10 месяцев назад +2

    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!!

  • @cappedvillain2522
    @cappedvillain2522 3 года назад +12

    More videos about macros please

  • @73nko
    @73nko 3 года назад +4

    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! 🙌

  • @jonxslays
    @jonxslays 3 года назад +7

    gettin into big boy stuff now 👌

  • @bonkbonk123
    @bonkbonk123 3 года назад +5

    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.

  • @KayOScode
    @KayOScode 2 года назад +4

    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

  • @cappedvillain2522
    @cappedvillain2522 3 года назад +25

    It's a little complicated... Can you spend some time elaborating with possible examples

    • @NoNamePerson18
      @NoNamePerson18 Год назад +2

      Here
      ruclips.net/video/geovSK3wMB8/видео.html
      This is a 4 hour long video on procedural Macros , and this is Part 1

  • @netify6582
    @netify6582 2 года назад +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.

  • @cj1871
    @cj1871 Год назад +1

    This really helped me understand derive macros, thanks so much!

  • @uoweme5grand
    @uoweme5grand 2 года назад +5

    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.

    • @pranavpolakam5371
      @pranavpolakam5371 Год назад +2

      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).

  • @allaboutworld5177
    @allaboutworld5177 11 месяцев назад

    Great series I had ever seen please add some more Projects too that would be more helpful thanks

  • @bjugdbjk
    @bjugdbjk 2 года назад +2

    Need Macro series very badly buddy !!

  • @chukwudiofoma6665
    @chukwudiofoma6665 Год назад

    Yes! I would love to see more videos.

  • @voidwalker7774
    @voidwalker7774 Год назад

    procedural macros for the gainzzz, buraaahh !!!

  • @subhamprasad1373
    @subhamprasad1373 11 месяцев назад +1

    macros are hard to understand... honestly i still confuse and lost

  • @in_action4737
    @in_action4737 Год назад

    How do I write a procedural macro which supports struct both with and without lifetime annotations?

  • @arjentix
    @arjentix 3 года назад +1

    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?

    • @DrumMeister
      @DrumMeister 2 года назад

      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?

    • @arjentix
      @arjentix 2 года назад +2

      ​@@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

  • @workflowinmind
    @workflowinmind 2 года назад

    How do you bring HelloMacro into scope 6:29? Should the derive crate have the macro on as dep?

  • @ashajjar
    @ashajjar 5 месяцев назад

    Is that AOP for Rust? :D

  • @arimcbrown
    @arimcbrown 2 года назад

    How much time does it cost for you to produce 1 video every time? (preparation included)

  • @rootkill1581
    @rootkill1581 3 года назад +4

    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)

  • @GrizikYugno-ku2zs
    @GrizikYugno-ku2zs 3 месяца назад

    It would help if you had realistic usecases. All of these macros should have been functions...

  • @soulelemanator97
    @soulelemanator97 Год назад

    I'm glad this video exits.

  • @RussianVegetables
    @RussianVegetables 2 года назад

    More vids on macros!

  • @Elite7555
    @Elite7555 11 месяцев назад

    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.

  • @pineiden
    @pineiden 2 года назад

    Nice, macros we're some obscure to me yet and i Will be thansfull if You can show more abour

  • @coldsir5406
    @coldsir5406 2 года назад

    Rust is easy, yes I said Rust is easy

  • @Ace-lp6bd
    @Ace-lp6bd 2 года назад

    Moar macros

  • @2002budokan
    @2002budokan 2 года назад

    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.

  • @nickshv8727
    @nickshv8727 2 года назад

    chishi

  • @max_ishere
    @max_ishere 2 года назад +1

    eh idk this seems too complicated for the general population of rustaceans

  • @redcrafterlppa303
    @redcrafterlppa303 2 года назад

    Looks like one of the sharp corners of rust. I really don't like the Syntax of this.