Ace Rust Macros ♠️ the declarative kind

Поділитися
Вставка
  • Опубліковано 4 вер 2024

КОМЕНТАРІ • 110

  • @ultrapoci
    @ultrapoci Рік тому +309

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

    • @ohturry5591
      @ohturry5591 Рік тому +14

      Lol😂

    • @ohturry5591
      @ohturry5591 Рік тому +8

      It’s an sql relationship 🤫

    • @codetothemoon
      @codetothemoon  Рік тому +45

      hah, in retrospect that was a poor choice 🙃

    • @ThanhNguyen-lk6ns
      @ThanhNguyen-lk6ns Рік тому +7

      It's a quantum teleportation 🤣

    • @furo.v
      @furo.v Рік тому +5

      I was going to comment the same thing lol

  • @robinmoussu
    @robinmoussu Рік тому +55

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

  • @perc-ai
    @perc-ai Рік тому +22

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

    • @codetothemoon
      @codetothemoon  Рік тому +3

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

  • @BrandonCharlesHouser
    @BrandonCharlesHouser Рік тому +4

    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 5 місяців тому

      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

  • @AceofSpades5757
    @AceofSpades5757 Рік тому +7

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

    • @codetothemoon
      @codetothemoon  Рік тому +2

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

  • @jeffg4686
    @jeffg4686 Рік тому +2

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

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

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

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

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

  • @tryoasnafi4340
    @tryoasnafi4340 Рік тому +4

    love your explanation style, simple, clear and well structured

  • @sparky173j
    @sparky173j Рік тому +6

    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  Рік тому +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...

  • @eduardopereira2431
    @eduardopereira2431 Рік тому +8

    Your Rust content its been incredible useful! Thank you!

  • @pup4301
    @pup4301 Рік тому +4

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

  • @luccao173
    @luccao173 8 місяців тому +1

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

  • @perc-ai
    @perc-ai Рік тому +3

    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

  • @Ma1ne2
    @Ma1ne2 Рік тому +4

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

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

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

  • @Akshay-be3qx
    @Akshay-be3qx Рік тому +2

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

  • @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 6 місяців тому

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

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

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

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

  • @aksakalaradhita
    @aksakalaradhita 11 місяців тому +1

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

    • @codetothemoon
      @codetothemoon  11 місяців тому

      would love to make such a thing!

  • @glebbash
    @glebbash Рік тому +2

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

  • @advanceringnewholder
    @advanceringnewholder 6 місяців тому +1

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

    • @codetothemoon
      @codetothemoon  6 місяців тому

      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 UA-cam video format

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

    Great concise content. Rust to the moon 🙂

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

    Lovely video! Love your pacing

  • @artursradionovs9543
    @artursradionovs9543 Рік тому +2

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

    • @codetothemoon
      @codetothemoon  Рік тому +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 Рік тому +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.

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

    3:39 Trolling is a art

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

    Love the way you teach us ,thank❤❤

  • @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 Рік тому +1

    Firstly, nice thumbnail, and then, nice video 👍

  • @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_ 10 місяців тому +2

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

    • @theaiguy_
      @theaiguy_ 10 місяців тому +2

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

    • @kavehtehrani
      @kavehtehrani 4 місяці тому

      @@theaiguy_ thank you kind stranger!

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

    It was cool! Thanks

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

    we call it the mustache brace around here.

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

      nice! sounds far better than "curly braces"

  • @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 💛💛

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

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

    ty

  • @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.

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

    Awesome 🙌🙌

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

    "Aces!" - 16 Candles

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

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

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

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

  • @Daveiac
    @Daveiac Рік тому +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 Рік тому +1

      Nah, compiler would infer their types are different and reject

    • @codetothemoon
      @codetothemoon  Рік тому +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

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

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

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

    Great stuff!

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

    Thanks!

  • @ambuj.k
    @ambuj.k Рік тому +1

    What is your vscode theme in this video?

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

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

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

    What is your color theme

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

    Do you have Rust for beginners?

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

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

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

      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 8 місяців тому +1

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

    • @codetothemoon
      @codetothemoon  8 місяців тому

      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 2 місяці тому

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

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

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