How to read complicated Rust types

How to read complicated Rust types

chris biscardi

2 года назад

52,488 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@jamese.spivak4170
@jamese.spivak4170 - 28.07.2022 16:13

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

Ответить
@earx23
@earx23 - 03.12.2023 16:56

This is some brainy shit. To be honest, I think many Rust programmers take this stuff way too far. Crazy levels of generic abstraction, but when I get the stopwatch out it factors slower than a naive implementation, which may not have been blessed with the same levels of abstraction, but is easily understood and manipulated. Still, thank you for analyzing, and getting to the bottom of things!

Ответить
@G11713
@G11713 - 18.11.2023 23:57

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

Ответить
@Ski4974
@Ski4974 - 22.10.2023 04:04

What window manager are you using?

Ответить
@zeroows
@zeroows - 28.06.2023 01:58

I love your videos. I wondered how best to create a pool of Reqwest clients and map them to Axum as "with_state".

Ответить
@GermanKuber
@GermanKuber - 27.06.2023 23:02

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.

Ответить
@lucasa8710
@lucasa8710 - 23.06.2023 00:20

Headache, this is all I can feel rn

Ответить
@foobar8894
@foobar8894 - 21.06.2023 01:32

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

Ответить
@BosonCollider
@BosonCollider - 21.06.2023 01:13

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.

Ответить
@Driver___
@Driver___ - 27.03.2023 01:48

So it should be read like this?
Self should implement Filter (with Error, where Error is Rejection) and Sized
F should implement Func (with Rejection)
F's associated type Output should implement TryFutere and Send
F's associated type Output for type TryFutere and this TryFutere's associated type Error should implement IsReject

Ответить
@MarcosVMSoares
@MarcosVMSoares - 12.03.2023 09:24

Amazing channel and video, but Rust still too hard to read and fully understand. I still prefer my elixir for doing WebAPI and use rust to complement when needed it.

Ответить
@Amapramaadhy
@Amapramaadhy - 28.12.2022 04:03

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.

Ответить
@haystackdmilith
@haystackdmilith - 19.10.2022 18:35

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

Ответить
@marko-lazic
@marko-lazic - 16.10.2022 19:10

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

Ответить
@avisalon4730
@avisalon4730 - 02.10.2022 12:17

Rust looks like overcomplicated languages. So why do we need it?

Ответить
@1e1001
@1e1001 - 29.09.2022 16:25

tip with your subtitles: try and keep them the same length-ish, usually a single or half of a sentence

Ответить
@fifty6737
@fifty6737 - 26.09.2022 20:35

the only confusing part is the where, yet the rust where restriction is powerful and typescript like

Ответить
@theglasstube3297
@theglasstube3297 - 10.09.2022 20:42

You catch on really fast, it seems complex but once you learn the basics it pretty much branches into experintation

Ответить
@qexat
@qexat - 06.09.2022 15:38

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!

Ответить
@IBKumar
@IBKumar - 06.09.2022 08:32

you know that by now tho

Ответить
@gangov
@gangov - 03.09.2022 00:31

thanks, Chris! How did you got so good at 'reading' Rust :D

Ответить
@DanelonNicolas
@DanelonNicolas - 01.09.2022 08:20

Hey Chris nice video!
Do you know where can I find architecture books for Rust?

Ответить
@allan710
@allan710 - 01.09.2022 02:20

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.

Ответить
@kevinhertelt7116
@kevinhertelt7116 - 25.08.2022 15:05

I like almost any content you create for us

Ответить
@michaelflynn6952
@michaelflynn6952 - 25.08.2022 10:22

gonna be real this did not help me at all, assumes way too much knowledge

Ответить
@Alguem387
@Alguem387 - 24.08.2022 16:40

"Handle rejection is gonna be that F" yep

Ответить
@officialp283
@officialp283 - 23.08.2022 16:06

How to read rust docs

Ответить
@maxcross5454
@maxcross5454 - 17.08.2022 15:42

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

Ответить
@HeimdallAfBifrost
@HeimdallAfBifrost - 17.08.2022 11:35

This is just jibberish. 😅

Ответить
@shaurz
@shaurz - 12.08.2022 15:39

I wish people would write full names for generic type variable instead of using a single capital letter.

Ответить
@michadarowny3811
@michadarowny3811 - 12.08.2022 11:44

Feels so boring, to read and understand that code

Ответить
@Tobi-gl2lb
@Tobi-gl2lb - 11.08.2022 19:12

Excellent walkthrough, thank you!

Ответить
@andydataguy
@andydataguy - 07.08.2022 03:31

Great video! Thank you 🙏🏾

Ответить
@ajf
@ajf - 07.08.2022 00:32

thx

Ответить
@angelajxne
@angelajxne - 29.07.2022 18:36

Thank You For TeacNice tutorialng Us Brother

Ответить
@netify6582
@netify6582 - 29.07.2022 13:43

Very well explained, thanks a lot!

Ответить
@christopher8641
@christopher8641 - 29.07.2022 04:57

Super helpful video !

Ответить
@walterwhite7924
@walterwhite7924 - 29.07.2022 01:27

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.

Ответить
@hasanmougharbel8030
@hasanmougharbel8030 - 28.07.2022 21:49

Hello there, God bless your efforts.
I am a new sql learner having a general enquiry.
How a company manages to write a documentation of its own sql application?
I would be so grateful for any kind of help.

Ответить
@ericktorres9791
@ericktorres9791 - 28.07.2022 21:44

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

Ответить