How to read complicated Rust types

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

I'm speechless. This was so incredibly helpful! Exactly what I was looking for and more. It's crazy how much info there is to unpack in that one example. Rust is so strict and descriptive, while not being overly verbose --- one of the reasons I'm loving this language. Anyway, really appreciate seeing your thought process as you tackle a complicated function like this and your ad-lib-ish teaching style! Looking forward to more vids

jamese.spivak
Автор

Sized is a marker trait, it is basically used to mark a type and say it can't be dynamic, which means that you can't have a Vec<dyn Filter> because Filter must be sized.

allan
Автор

Story of my life. I don't handle rejection very well and I always get into generic arguments with people.

foobar
Автор

YOU ARE AMAZING! Your channel is so underrated. Every video that you create is always approachable and easy to follow, even without understanding everything. Thanks so much for everything that you do <3

ericktorres
Автор

Reading doc is super power that no one want to teach you because this is the source of their super power.
I'm gonna start learning from the docs itself.

Cawnnak
Автор

This is gold beginners like me avoid docs as long as possible cos its seems overwhelming but you broke it down clearly cannot thank you enough

Said-no
Автор

The quick answer I would give for this case, is that it is a method on a trait that returns a type which has the same name as the function but in uppercase.

In those cases, the very first thing I would check is whether the returned type satisfies the trait it is defined on, in this case whether it returns a filter. In those cases, the idea is generally that you do not care what specific filter you have, you just care that you have an object satisfying that interface, and filter is a method that takes a filter and return a filter, possibly modifying it/adding middleware in some way.

BosonCollider
Автор

Wow! Learning Rust for a month now. This was very helpful.

MattThiessen
Автор

Great content!.. A video like this does more to an advanced level programming than any hard code programming video can do.. thus with a proper and effective way to look into documentation you're half way there.

josebaiturregui
Автор

I greatly value this video for its immense usefulness, as it provides a wealth of valuable insights and information. Your generosity in sharing such valuable knowledge is deeply appreciated, and it demonstrates your commitment to empowering others through education and enlightenment.

Автор

I'm actually very surprized how intuitive this function looks. If you just know the consept of traits and at least heard of associated types, then this code means exactly what it's looks like:

Self: has to implement filter trait, associatied type Error of witch has to be Rejection, and it also has to implement Func;
F: has to implement Func with generic arg Rejection
F::Output (associated type of Func, since we already specified that F implements Func) has to implement traits TryFuture + Send,
F::Output::Error (associated type of TryFuture, as we manualy speccified) has to implement IsReject.



The only two things that are not really clear for me:
1) Why we HAVE TO speccify F::Output as TryFuture to set constraint to Error, but don't have to specify F as Func to set constraint to Output? I thought that this is because Output constrained to implement 2 traits (TryFuture + Send), but if i remove Send, it still won't compile unless I manualy speccify Output as TryFuture...

2) Why I get an error if I remove Sized constraint from Self? I thought that the type of Self already has to be known at compile time => size also has to be known.
Actually, I found answer to the second question: it's because trait object exist (dyn &MyTrait), so theoreticly Self can be not known at compile time. Still, a bit confusing...

maxcross
Автор

I like almost any content you create for us

kevinhertelt
Автор

Good content. Very informative and worth a sub. I found this via the homepage. Ive been consuming some rust related content lately. Never used the language yet and Ive been put off by many cases like this. As a personal background I am a hobbyist developer with primarily java experience.

walterwhite
Автор

Hi Chris, I'm very thankful for the subtitles. Could you make them a bit more split please? The wall of text sometimes hides the video and it can be hard to focus to read all in once. Thank you in advance!

qexat
Автор

Amazing videos. I am glad you are getting so many views.

marko-lazic
Автор

Couldn't be more confusing lol. The worst part of rust is trying to step out of your comfort areas.

Ny_babs
Автор

Nice. It is also important to note that this `recover` method consumes its object, `self`.

G
Автор

FYI at 7:04 you could have used the little arrow in the top left corner to expand the file list and opened recover.rs from there!

charltonrodda
Автор

Thanks for this. The associated type thing helped me a lot! <3

haystackdmilith
Автор

Love it!
Speaking of breaking things down, I'd love for you to do a video on "how to grok the rust docs"! Half the time, I give up when I cant _effectively_ look things up in the docs. I feel like it has its own grammar so to speak.

Amapramaadhy
visit shbcf.ru