Mr Stropek you are one of the best exposer i“ve ever heard on the topic. This talk was invaluable for me! Thanks a lot. Rust, give this man more talks please. And ty you too.
@robertmullings7481
2 жыл бұрын
Had to add a comment. Rainer, that was a brilliantly conceived and delivered talk. One of the clearest on Rust I have heard so far. Keep up the good work!
@TinBryn
2 жыл бұрын
A small correction at 4:46 you said the line "let f: fn add(i32, i32) -> i32 = add;" declares "f" as a function pointer. "f" is actually a function item which is a zero sized type that statically represents a specific function. If you made it mutable and later assigned it to "fn sub(i32, i32) -> i32" this would fail to compile
@Dorumin
2 жыл бұрын
Yeah I knew there was something off about "function pointer", thanks
@Roms8313
2 жыл бұрын
that was just perfect recap, glad you introduced the 2021 features too !
@KaneYork
2 жыл бұрын
Yes, this is essentially how the syntax is done in Ruby! A language famous for being extremely difficult yet still deterministic to parse.
@thanhtan030t
3 ай бұрын
the presentation skill is impressive. thank you, sir!
@sagnikbhattacharya1202
2 жыл бұрын
Great talk, I just have a meme 32:23 Rainer: You can use disjoint closures in real-world examples. Also Rainer: *Literally uses disjoint closures in a fairy tale example*
@kaypope1581
2 жыл бұрын
Wow, I never thought about FnOnce like case in closure context before. I guess Rust force you to think about all these details and subtle differences. Thanks for the awesome presentation.
@luizchagasjardim
2 жыл бұрын
Great talk. Lambdas are one of the few things where I prefer the C++ version. In C++ it's clearer what's being captured and what kind of capture it's using for each variable.
@nirmalyasengupta6883
Жыл бұрын
The way you have explained, is quite useful. Coming from the Scala world, I am trying to map my understanding between two languages (and their philosophies). This presentation supplements that very well. Thank you.
@Galakyllz
Жыл бұрын
This was very well done. I really appreciate this talk; I definitely learned something.
@func0der
2 жыл бұрын
Thank you very much for this clear explanations. Though I am not very strong in Rust (kind of post-beginner), I was able to follow it. I just have to make me a refresher on concepts like dyn keyword with Traits. But for sure, I can find many videos/blogs explaining this concept. Very good video.
@saaddahmani1870
2 жыл бұрын
Great, your explanation is so clear.... thanks.
@changtimwu
2 жыл бұрын
Great talk about rust closures. I have a question irrevalent to Rust. How did you annotate certain area of code in vscode during desktop recording? Is it a featue of your live broadcast software?
@LukeAvedon
2 жыл бұрын
It's that C# guy!!!
@johnfunk1815
2 жыл бұрын
Greats concise explanations.
@yuribudilov5638
2 жыл бұрын
great talk, thank you
@theherk
2 жыл бұрын
I'm confused by the use of the term closure for all the examples around the 7 minute mark. They seem to be just lambdas or anonymous functions, and they don't close over any values from the environment. They don't use arguments from the surrounding scope, so why are they closures?
@jhbonarius
2 жыл бұрын
"You can remove the parentheses and make it even nicer" ...i wish everybody thought like that I had a discussion with my tech lead (C#) and proposed thing like that. He hated it. He still seems to have problems with moving from VB to C#, and would even prefer to use "end function" and such over parentheses...
@jhbonarius
2 жыл бұрын
Wow, needing to box the closure which allocates on the heap when you reference an external variable seems heavy! C++ lambda capture by reference seems much more lightweight in comparison
@deanroddey2881
2 жыл бұрын
Yeh, that seems odd. I would have thought you could just pass it as 'dyn Fn" without the box. I can't imagine anyone would want to pay that cost for invocation of the kind of trivial to semi-trivial code often done in lambas/closures. I would also take exception to his claim that Rust is very explicit. There's a huge amount of magical syntactical sugar in Rust.
@trolledwoods377
2 жыл бұрын
You don't need to, you can use &dyn Fn, &mut dyn FnMut, make the closure a generic of the fy ction instead etc... There are lots of options
@jhbonarius
2 жыл бұрын
@@trolledwoods377 ok, that's good. But these need to be properly taught. This video is not doing that. It's confusing experienced in programming, but new to Rust.
@ChumX100
2 жыл бұрын
@@jhbonarius I suppose the reason Box is used here instead of bare references is that Box takes ownership of the values it wraps, while references do not, so with references, lifetime annotations would sometimes be necessary and would make the code more difficult to understand.
@tsg1zzn
2 жыл бұрын
I was also surprised to see this, so I tested it. It is possible to pass by reference. ``` fn main() { fn add(x: i64, y: i64) -> i64 { x + y } fn calc_and_print(x: i64, y: i64, calcfn: &dyn Fn(i64, i64) -> i64) { let result = calcfn(x, y); println!("{}", result); } calc_and_print(1, 2, &add); calc_and_print(1, 2, &|x, y| x + y); let z = 5; calc_and_print(1, 2, &|x, y| x + y + z); } ```
@emvdl
2 жыл бұрын
Thanks
@azizul_islam
11 ай бұрын
font size too small :(
@quickD11
2 жыл бұрын
Great Explanation, however I'd like to leave a comment: at kzitem.info/news/bejne/w52Qx22Mi3SZjIo you do not actually need to do boxing, accept `&dyn Fn(i32, i32) -> i32` instead. In such a case, explicit lifetimes can also be dropped.
Пікірлер: 29