Learning Rust: Procedural Macros

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 32

  • @fabiomencoboni3587
    @fabiomencoboni3587 3 роки тому +8

    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.

    • @devonduty
      @devonduty  3 роки тому

      Thank you! Glad I could help!

  • @yumbuboyumbubo8230
    @yumbuboyumbubo8230 Рік тому +1

    Wow, this is the exact problem I try to tackle for a long time! It will jumpstart my progress. Subbed!

  • @johanngambolputty5351
    @johanngambolputty5351 Рік тому +1

    You don't need to make a closure right 'filter_map(|field| get_entity_field(field))'? 'filter_map(get_entity_field)' should work?

    • @devonduty
      @devonduty  Рік тому

      Thank you, yes, that should also work!

  • @NeotenicApe
    @NeotenicApe 2 роки тому

    This is exactly what I've been looking for. Great videos. You never miss. Thanks so much.

  • @kiffeeify
    @kiffeeify 2 роки тому +2

    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?

    • @devonduty
      @devonduty  2 роки тому +1

      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/

    • @Luxalpa
      @Luxalpa 2 роки тому +1

      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.

  • @boringlymines
    @boringlymines 3 роки тому +4

    I’m still to wrap my head around all the things he blew by the explanation

  • @rishadbaniya
    @rishadbaniya 3 роки тому +1

    I need more about macros

  • @fixer8173
    @fixer8173 3 роки тому +1

    Great series!

    • @devonduty
      @devonduty  3 роки тому

      Thanks a lot, NoPartiesGuy!

  • @verified_tinker1818
    @verified_tinker1818 Рік тому

    Thanks for the video! Is there any reason you used the match statement instead of the `?` operator?

    • @devonduty
      @devonduty  Рік тому

      Good question, to be honest I don't remember. Usually I strongly prefer `?` over match.

  • @MMABeijing
    @MMABeijing 2 роки тому +2

    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

    • @devonduty
      @devonduty  2 роки тому +1

      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.

  • @adsick_ua
    @adsick_ua 2 роки тому

    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.

    • @devonduty
      @devonduty  2 роки тому

      That's true, thanks for commenting!

  • @JeremyChone
    @JeremyChone 3 роки тому +1

    Nice video.

  • @NeevekEst
    @NeevekEst 2 роки тому +1

    Nice tutorial on the topic but the inlay hint is quite messy and is distracting.

    • @devonduty
      @devonduty  2 роки тому

      Thanks for the feedback!

  • @hirisraharjo
    @hirisraharjo 3 роки тому +2

    Nice tutorial. But please turn off the music completely next time because your explanations are more important than the music

    • @devonduty
      @devonduty  3 роки тому +1

      Hi Haris, thanks! Yes, in all my newer videos I turned off the music completely.

  • @pinch-of-salt
    @pinch-of-salt 3 роки тому +2

    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.

    • @devonduty
      @devonduty  3 роки тому +1

      Thank you! I did already make a tutorial on the vim setup: ua-cam.com/play/PLu-ydI-PCl0OEG0ZEqLRRuCrMJGAAI0tW.html

    • @pinch-of-salt
      @pinch-of-salt 3 роки тому +1

      @@devonduty again. I love your videos man! I am subbed!

    • @devonduty
      @devonduty  3 роки тому

      @@pinch-of-salt Thanks a lot!

  • @Florian-sh9nf
    @Florian-sh9nf 2 роки тому

    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.

  • @Karechta
    @Karechta 3 місяці тому

    Liked the video, hated the Music