Ace Rust Macros ♠️ the declarative kind

  Рет қаралды 42,412

Code to the Moon

Code to the Moon

Күн бұрын

Пікірлер
@ultrapoci
@ultrapoci 2 жыл бұрын
Assigning "Bob" to variable "a" and "Alice" to variable "b" is just evil
@ohturry5591
@ohturry5591 2 жыл бұрын
Lol😂
@ohturry5591
@ohturry5591 2 жыл бұрын
It’s an sql relationship 🤫
@codetothemoon
@codetothemoon 2 жыл бұрын
hah, in retrospect that was a poor choice 🙃
@ThanhNguyen-lk6ns
@ThanhNguyen-lk6ns 2 жыл бұрын
It's a quantum teleportation 🤣
@furo.v
@furo.v 2 жыл бұрын
I was going to comment the same thing lol
@robinmoussu
@robinmoussu 2 жыл бұрын
I definitively love your style. Clear, short, on-topic!
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Robin!!
@TripleNipplFishh
@TripleNipplFishh Жыл бұрын
I have to say, you really got the best Rust content. exactly the right tempo and right hints
@codetothemoon
@codetothemoon Жыл бұрын
thanks so much!
@perc-ai
@perc-ai 2 жыл бұрын
This is the best rust macro video on KZbin! Looking forward to all your future videos your quickly brecoming an industry leader
@codetothemoon
@codetothemoon 2 жыл бұрын
wow thanks for the kind words! I really enjoy making them!
@asnafix
@asnafix 2 жыл бұрын
love your explanation style, simple, clear and well structured
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Tryo!
@AceofSpades5757
@AceofSpades5757 2 жыл бұрын
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 🙃
@eduardopereira2431
@eduardopereira2431 2 жыл бұрын
Your Rust content its been incredible useful! Thank you!
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Eduardo, thanks for watching!
@Ma1ne2
@Ma1ne2 2 жыл бұрын
Loving these Rust videos so much, great to follow along and learn something new :) Keep them coming!
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Noxdor, glad you are finding them valuable! more to come!
@BrandonCharlesHouser
@BrandonCharlesHouser Жыл бұрын
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 Жыл бұрын
ahh didn't know about this, thank you!
@egorsozonov7425
@egorsozonov7425 10 ай бұрын
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
@sparky173j
@sparky173j 2 жыл бұрын
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 жыл бұрын
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...
@Akshay-be3qx
@Akshay-be3qx 2 жыл бұрын
Really cool way to explain. Thanks for taking time to make awesome videos.
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks for watching Akshay!
@perc-ai
@perc-ai 2 жыл бұрын
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
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Zah, more are on the way!
@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
@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 2 жыл бұрын
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).
@HyperFocusMarshmallow
@HyperFocusMarshmallow Жыл бұрын
Great introduction!!! It would be cool if you did one or a few follow ups of more advanced macros.
@ErikSchierboom
@ErikSchierboom 2 жыл бұрын
Lovely video! Love your pacing
@tuanlam999
@tuanlam999 2 жыл бұрын
Great concise content. Rust to the moon 🙂
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Tuan! 🌙
@rockNbrain
@rockNbrain Ай бұрын
Great job bro!!
@codetothemoon
@codetothemoon Ай бұрын
Thank you, glad you liked it!
@tonhom260
@tonhom260 Жыл бұрын
Love the way you teach us ,thank❤❤
@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_ Жыл бұрын
That is because a can be anything, 5 included, so it matches.
@theaiguy_
@theaiguy_ Жыл бұрын
Usually the general case is named "_", but really can be anything
@kavehtehrani
@kavehtehrani 9 ай бұрын
@@theaiguy_ thank you kind stranger!
@aksakalaradhita
@aksakalaradhita Жыл бұрын
Man, you should have "in-depth rust" series
@codetothemoon
@codetothemoon Жыл бұрын
would love to make such a thing!
@glebbash
@glebbash 2 жыл бұрын
Great stuff, sounds like macros are not that scary after all.
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks, indeed they are not! 😎
@advanceringnewholder
@advanceringnewholder 11 ай бұрын
I wish you deep dive into procedural macro. I'm having a hard time wrapping my head around it.
@codetothemoon
@codetothemoon 11 ай бұрын
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 KZbin video format
@pierreniberon1801
@pierreniberon1801 2 жыл бұрын
Firstly, nice thumbnail, and then, nice video 👍
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Pierre!
@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 2 жыл бұрын
@@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.
@Daveiac
@Daveiac 2 жыл бұрын
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 жыл бұрын
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
@legends_assemble4938
@legends_assemble4938 Жыл бұрын
Can u create a video on getting started with procedural macros.
@codetothemoon
@codetothemoon Жыл бұрын
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 💛💛
@AzureFlash
@AzureFlash 2 жыл бұрын
3:39 Trolling is a art
@codetothemoon
@codetothemoon 2 жыл бұрын
If I trolled it wasn't intentional! 🙃
@africknchickn_YT
@africknchickn_YT 2 жыл бұрын
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 2 жыл бұрын
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 11 ай бұрын
​@@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
@ozkavoshdjalla
@ozkavoshdjalla 2 жыл бұрын
It was cool! Thanks
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks for watching Ozkavosh!
@narayanbhat3279
@narayanbhat3279 2 жыл бұрын
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.
@diwakargupta0
@diwakargupta0 2 жыл бұрын
Awesome 🙌🙌
@codetothemoon
@codetothemoon 2 жыл бұрын
glad you found it valuable!
@KyuuKun16
@KyuuKun16 2 жыл бұрын
Your videos are AMAZING, would you consider making one delving deeper into concurrency?
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Jason, I'd love to do one on concurrency - it's already on the video idea list!
@grindarius661
@grindarius661 2 жыл бұрын
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 2 жыл бұрын
@@codetothemoon what font are you using?
@zencephalon
@zencephalon 2 жыл бұрын
Great stuff!
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks Matthew!
@ambuj.k
@ambuj.k 2 жыл бұрын
What is your vscode theme in this video?
@codetothemoon
@codetothemoon 2 жыл бұрын
Sonokai
@codeplay4947
@codeplay4947 2 жыл бұрын
What is your color theme
@codetothemoon
@codetothemoon 2 жыл бұрын
Sonokai
@codeplay4947
@codeplay4947 2 жыл бұрын
@@codetothemoon Do you mean Monokai...I couldn't find Sonokai
@alurma
@alurma Жыл бұрын
ty
@codetothemoon
@codetothemoon Жыл бұрын
you're welcome thanks for watching!
@glennmiller394
@glennmiller394 2 жыл бұрын
Thanks!
@codetothemoon
@codetothemoon 2 жыл бұрын
Thanks for watching Glenn!
@jaromor8808
@jaromor8808 2 жыл бұрын
what's up with that extra/last comma in the dbg! output?
@van3ll0pe
@van3ll0pe 2 жыл бұрын
C > rust I love c
@codetothemoon
@codetothemoon 2 жыл бұрын
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 Жыл бұрын
@@codetothemoon Rust doesn't segfault enough. A real language segfaults at least three times before breakfast.
@Elduque40
@Elduque40 2 жыл бұрын
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).
@tsalVlog
@tsalVlog Жыл бұрын
we call it the mustache brace around here.
@codetothemoon
@codetothemoon Жыл бұрын
nice! sounds far better than "curly braces"
@kennethbeal
@kennethbeal 2 жыл бұрын
"Aces!" - 16 Candles
@codetothemoon
@codetothemoon 2 жыл бұрын
Hah, I had to look this up!
@tactics40
@tactics40 2 жыл бұрын
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 2 жыл бұрын
Ahh good point I was sort of using those terms interchangeably, but like you say in the world of macros they are different!
@banocean
@banocean Жыл бұрын
Tbh your videos now are kinda let's do thing I can read in the docs/rust book :/
@codetothemoon
@codetothemoon Жыл бұрын
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 7 ай бұрын
Bro, your tutoriall are amazing, post discord or telegram groups please♥️🙏
@marcelo55869
@marcelo55869 2 жыл бұрын
𝓑𝓛𝓐𝓩𝓘𝓝𝓛𝓨 𝓕𝓐𝓢𝓣
Is Rust the New King of Data Science?
15:38
Code to the Moon
Рет қаралды 141 М.
Rust Interior Mutability - Sneaking By The Borrow Checker
16:02
Code to the Moon
Рет қаралды 77 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Declarative Macros in Rust
6:56
Let's Get Rusty
Рет қаралды 37 М.
rust macros are magic
14:02
Tantan
Рет қаралды 51 М.
Using polymorphic async closures in rust
9:50
MathiasCodes
Рет қаралды 2,3 М.
Rust Branching - if let, match
9:21
Code to the Moon
Рет қаралды 30 М.
Rust's Witchcraft
9:18
No Boilerplate
Рет қаралды 192 М.
Rust vs Java: A Staff Engineer's perspective
25:04
Dario
Рет қаралды 24 М.
Rust: When C Code Isn't Enough
8:26
CodeAhead
Рет қаралды 180 М.
Rust Powered Polymorphism ⚡️ With Traits
9:55
Code to the Moon
Рет қаралды 110 М.
1 billion row challenge in Rust using Apache Arrow
9:12
Josiah Parry
Рет қаралды 10 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 166 М.