Ace Rust Macros ♠️ the declarative kind

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

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

  • @ultrapoci
    @ultrapoci 2 года назад +317

    Assigning "Bob" to variable "a" and "Alice" to variable "b" is just evil

    • @ohturry5591
      @ohturry5591 2 года назад +14

      Lol😂

    • @ohturry5591
      @ohturry5591 2 года назад +8

      It’s an sql relationship 🤫

    • @codetothemoon
      @codetothemoon  2 года назад +47

      hah, in retrospect that was a poor choice 🙃

    • @ThanhNguyen-lk6ns
      @ThanhNguyen-lk6ns 2 года назад +7

      It's a quantum teleportation 🤣

    • @furo.v
      @furo.v Год назад +5

      I was going to comment the same thing lol

  • @robinmoussu
    @robinmoussu 2 года назад +56

    I definitively love your style. Clear, short, on-topic!

  • @perc-ai
    @perc-ai 2 года назад +23

    This is the best rust macro video on RUclips! Looking forward to all your future videos your quickly brecoming an industry leader

    • @codetothemoon
      @codetothemoon  2 года назад +3

      wow thanks for the kind words! I really enjoy making them!

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

    I have to say, you really got the best Rust content. exactly the right tempo and right hints

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

    love your explanation style, simple, clear and well structured

  • @AceofSpades5757
    @AceofSpades5757 2 года назад +8

    That was a really good, light introduction into Rust's declarative macros. Thanks!

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

      Thanks AceofSpades! It's almost as if the title and thumbnail were speaking directly to you 🙃

  • @BrandonCharlesHouser
    @BrandonCharlesHouser Год назад +5

    In VS Code, if you hold alt and then press the up or down arrow it will move the line you are on or your entire selection up or down. It's great for reorganizing switch statements, if else ladders, and just re-organizing code.

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

      ahh didn't know about this, thank you!

    • @egorsozonov7425
      @egorsozonov7425 7 месяцев назад

      It’s not great, it’s terrible. Pressing Alt and arrows at the same time requires you to move your hand very far from the home row! Better editors like Neovim have saner hotkeys as well as a way to reassign them arbitrarily

  • @eduardopereira2431
    @eduardopereira2431 2 года назад +9

    Your Rust content its been incredible useful! Thank you!

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

      Thanks Eduardo, thanks for watching!

  • @sparky173j
    @sparky173j 2 года назад +7

    Thankyou for this and all your other videos. I usually prefer learning these things from video demos over documentation.
    I've been procrastinating adding macros to my project. I'll probably mostly be using derive macros, but I think declarative macros will be a good place to start.

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

      Thanks for watching tev. I really enjoy making them, especially when I get comments like this! Declarative macros can be a great place to start (though you don't have to). Will probably be making a custom derive video at some point...

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

    Loving these Rust videos so much, great to follow along and learn something new :) Keep them coming!

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

      Thanks Noxdor, glad you are finding them valuable! more to come!

  • @perc-ai
    @perc-ai 2 года назад +4

    Hey there’s a new wave of rust developers especially after all the news that rust is changing everything… would love to see more videos from you

  • @jeffg4686
    @jeffg4686 2 года назад +3

    Found an interesting syntax today, which is tuple pattern matching, where all elements of the tuple value can become 'wildcard' matches / variables'.

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

      I find this feature super handy, I think it's called "destructuring"!

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

      @@codetothemoon - yeah, it's destructuring, but never seen it before in this context (matching).

  • @Akshay-be3qx
    @Akshay-be3qx 2 года назад +3

    Really cool way to explain. Thanks for taking time to make awesome videos.

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

    Hey remember you can use the rust language reference to help under stand the token syntax of a macro!

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

    Each video by you is to the point, and really it has helped me a lot.
    E.g, the video on 'result', I knew Result enum, but after watching it I learned the use case for map_err. Thank you

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

    Great introduction!!! It would be cool if you did one or a few follow ups of more advanced macros.

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

    Man, you should have "in-depth rust" series

  • @africknchickn_YT
    @africknchickn_YT Год назад +3

    if you do a similar walkthrough for proc macros, I *will* subscribe. In my experience, building a custom derive is a more common use case that I wish I had the time to learn in detail how to do, as opposed to defining and parsing a new DSL. So (if you're taking votes...) my vote would be for doing a recursive derive of structs and enums!
    If not, then no worries :) I'll still be around. Cheers dude!

    • @codetothemoon
      @codetothemoon  Год назад +6

      Nice, I've been thinking a lot about a proc macro video. I've found it incredibly challenging to explain those concepts in a concise and digestable way - I think it can be done though! Thanks for watching!

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

      ​@@codetothemoon yeah! I've just been watching "9 rules for procedural macros" and my head is still swimming.

    • @advanceringnewholder
      @advanceringnewholder 8 месяцев назад

      ​@@codetothemoonCheering on that. I hope you'll make that video and adding it to the knowledge pool of easy to digest video. Take your time

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

    Love the way you teach us ,thank❤❤

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

    Great concise content. Rust to the moon 🙂

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

    Lovely video! Love your pacing

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

    3:39 Trolling is a art

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

      If I trolled it wasn't intentional! 🙃

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

    Great stuff, sounds like macros are not that scary after all.

  • @advanceringnewholder
    @advanceringnewholder 8 месяцев назад +1

    I wish you deep dive into procedural macro. I'm having a hard time wrapping my head around it.

    • @codetothemoon
      @codetothemoon  8 месяцев назад

      yeah i'd love to do this. i actually started writing a video about it awhile back but found it really difficult to present it in a clear way in the RUclips video format

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

    "Aces!" - 16 Candles

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

    Your videos are AMAZING, would you consider making one delving deeper into concurrency?

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

      Thanks Jason, I'd love to do one on concurrency - it's already on the video idea list!

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

    Firstly, nice thumbnail, and then, nice video 👍

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

    Is there a way to specify the types of elements to the set? Like what if you were to do set!(1,"2",'3'), would it compile?

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

      Nah, compiler would infer their types are different and reject

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

      yeah like Ian mentions, the HashSet itself has to be of a specific type so this wouldn't compile - this isn't related to the macro itself, it would still happen if you tried to do that directly with HashSet::from

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

    we call it the mustache brace around here.

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

      nice! sounds far better than "curly braces"

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

    It was cool! Thanks

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

    Awesome 🙌🙌

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

    what's up with that extra/last comma in the dbg! output?

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

    C > rust
    I love c

    • @codetothemoon
      @codetothemoon  Год назад +3

      What do you like most about C that Rust falls short on? What issues do you think C has that could be addressed in a future language?

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

      @@codetothemoon Rust doesn't segfault enough. A real language segfaults at least three times before breakfast.

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

    ty

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

    Can u create a video on getting started with procedural macros.

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

      I'd love to do that, and I actually started writing a script on at least one occasion, but I've found them to be incredibly challenging to explain in a simple way. I'll come back to it at some point 😎

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

      @@codetothemoon Thanks for considering my request 💛💛

  • @eddex.
    @eddex. Год назад +2

    Why did the "thing = 5" variable match the "a arm"? And how can it match "a" when there's no variable called "a"?

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

      That is because a can be anything, 5 included, so it matches.

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

      Usually the general case is named "_", but really can be anything

    • @kavehtehrani
      @kavehtehrani 6 месяцев назад

      @@theaiguy_ thank you kind stranger!

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

    Thanks!

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

    Great stuff!

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

    shouldn't you first create an empty hashset and then push each of the elements into the set?

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

      That would work too. I'm honestly not sure which approach is more efficient.

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

    What kind of theme are you using? It is so cool and I wanted to know the name of it.

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

      Thanks, it's Sonokai!

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

      @@codetothemoon what font are you using?

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

    Does anyone know how to implement Stripe and JWT in rust for e-commerce

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

      I second this. I've been mulling a Stripe video for some time, definitely a huge area of interest. For JWT / OAuth in Rust I actually did a video on that several months ago

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

      @@codetothemoon no official docs available. I love Rust a lot, but it takes a lot of time as a beginner to pick this up. My goal is to develop a small Android Native App with Actix as a backend framework, but note sure if I will succeed. Rust really is harder than Java, Python or JS.

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

    nit: println takes a string literal, not a slice. One of the hallmarks of a macro is that it can distinguish the two whereas functions can't.

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

      Ahh good point I was sort of using those terms interchangeably, but like you say in the world of macros they are different!

  • @ambuj.k
    @ambuj.k Год назад +1

    What is your vscode theme in this video?

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

    What is your color theme

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

    Do you have Rust for beginners?

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

      Check out "Rust Demystified"! It goes straight to the heart of what makes Rust different from other languages

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

      The best I've read is this book: Programming Rust by Jason Orendorff, Jim Blandy, and Leonora F .S. Tindall, O'Reilly. It covers the last 2021 edition, is superbly written and covers all the topics by explaining everything with a good learning curve. I've heard good things about The Rust Programming Language by Steve Klabnik and Carol Nichols, no starch press, but it's outdated (a new edition should be available later next year).

  • @banocean
    @banocean 10 месяцев назад +1

    Tbh your videos now are kinda let's do thing I can read in the docs/rust book :/

    • @codetothemoon
      @codetothemoon  10 месяцев назад

      thanks for the feedback. I only make videos on topics that are covered in the Rust book if I think i can offer a different approach and explanation that makes it easier to understand, which was the case for this video. Another example would be the one on interior mutability. Maybe I missed the mark on this one!

  • @Singlton
    @Singlton 4 месяца назад

    Bro, your tutoriall are amazing, post discord or telegram groups please♥️🙏

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

    𝓑𝓛𝓐𝓩𝓘𝓝𝓛𝓨 𝓕𝓐𝓢𝓣