Rust Linz, July 2021 - Rainer Stropek - Traits, not your grandparents' interfaces

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

ความคิดเห็น • 43

  • @CompletelyCovered3
    @CompletelyCovered3 3 ปีที่แล้ว +26

    Rainer seems like a great guy. Helpful, clear, and humble.

  • @建平許
    @建平許 3 ปีที่แล้ว +33

    Awesome! The speaker has a great passion for Rust.

  • @9SMTM6
    @9SMTM6 3 ปีที่แล้ว +12

    Nice so far.
    Just a small nitpick, at 13:20: Pretty sure that "Auto-Implementation" is already (pretty much) used for something else, and even ignoring that thing there's other mechanisms that could be named the same.
    Auto-Trait-Implementations is reserved for things that a user usually doesn't interface with directly, stuff like Sync (which gets imemented automatically on any type that is made up out of elements that implement Sync), Send etc.
    These get implemented entirely without user interaction, while the things refered to in the talk still need to be explicitly opted in, even if that is with minimal boilerplate.
    These traits refered to in the talk, eg Clone, Copy, Hash etc, are called "Derivable traits".
    There's also YET ANOTHER mechanism, called "Banket Implementations". These are also powerful and interesting. One example is the Conversion Traits "From" and "Into", which can handle eg conversions between &str and String. As the documentation of these mentions you usually only want to Implement "From" on the target type, this will automatically create an implementation of "Into" on the source type via Blanket Implementation. So, if you implement "From for String" the compiler will generate a perfect implementation of "Into for &str".

  • @pyrysaarinen4954
    @pyrysaarinen4954 2 ปีที่แล้ว +1

    This is the most enthusiasm i Have ever seen for someones cause

  • @yapayzeka
    @yapayzeka ปีที่แล้ว +1

    15:30 according to Rust docs; use From for imlementation and use Into for trait bounds.
    Examples:
    Implementing From you can see in the video:
    impl From for SquareContent { ... }
    Trait bounds for Into only accepts parameters that are castable to SquareContent. we implemented From earlier so we can pass u8 because we know how to make SquareContent from u8;
    fn my_super_function(param: T) -> SquareContent
    where
    T: Into,
    {
    ...
    }

  • @thalianero1071
    @thalianero1071 2 ปีที่แล้ว +3

    I’d like to take a moment to say that a tied tic-tac-toe match is called a “cat’s game”

  • @2002budokan
    @2002budokan 2 ปีที่แล้ว +1

    The essential ideas behind the traits are explained by a passioned developer. Thank you, this is the first time that I see a trait is more than an interface.

  • @willinton06
    @willinton06 3 ปีที่แล้ว +8

    Rust is so ahead of the curve, as a C# guy I’m kinda jealous

    • @SimonClarkstone
      @SimonClarkstone 3 ปีที่แล้ว +4

      I'm a C# and Java programmer, and I would like to use them too.
      As one of the attendees pointed out, Rust traits are similar to typeclasses in Haskell, which have been around since the 90s at least. (I am familiar with them in Haskell.)

  • @robinmoussu
    @robinmoussu 2 ปีที่แล้ว +2

    I love your energy Rainer. That’s a great talk that I will recommend.

  • @Amapramaadhy
    @Amapramaadhy ปีที่แล้ว +6

    I was confused by the `From`/`into` until it dawned on me that you are _not_ doing a reverse operation! It was subtle for me. Using pseudo-code, `Widget::From(1)` can simply be re-stated as `1.into()` which returns the same widget. This way, its a different syntax for writing the same thing that can come handy in some situation, e.g more ergonomic api with chained operation.
    (This would be very different from say `Widget.into()` to return a 1 but thankfully thats not whats happening here. )

    • @Gruby7C1h
      @Gruby7C1h ปีที่แล้ว +1

      Exactly, having "impl From for Sausage" doesn't magically implement a conversion that would allow us to make the poor pig back from our meal.

  • @irlshrek
    @irlshrek 2 ปีที่แล้ว +4

    loved this! genuinely helped me understand traits better

  • @marko-lazic
    @marko-lazic ปีที่แล้ว

    Thank you so much. I filled some gaps about traits by watching the video.

  • @sumansaha295
    @sumansaha295 2 ปีที่แล้ว +1

    This is a very in-depth video about rust features. Thanks!

  • @nickschmitt8594
    @nickschmitt8594 3 ปีที่แล้ว +11

    What an incredible educator.

  • @frroossst4267
    @frroossst4267 11 หลายเดือนก่อน

    This is an absolutely amazing talk!

  • @ikhlasulkamal5245
    @ikhlasulkamal5245 ปีที่แล้ว +1

    Wait, did you said Ferris cake? I want one please

  • @Zaniahiononzenbei
    @Zaniahiononzenbei 2 ปีที่แล้ว +1

    I'm definitely confused with implementing into_iter. I'm understanding that you can add "parameters" to interfaces in some sense. Essentially, only as types.
    All I can see from the example is a daunting pile of various versions of "into" and "iter", with various joining characters.
    It makes sense to inform the compiler that the calling code will get an item of a specific type when iterating. It makes sense to reuse the into_iter implemented on an array. I'm having difficulty understanding the function.
    If I'm understanding the code right, we're saying we're going to return the same type that calling into_iter on an array of length 9 would return? Are these identical?
    IntoIterator::Into_iter(self.board_content)
    self.board_content.into_iter()

    • @piguyalamode164
      @piguyalamode164 ปีที่แล้ว

      Yes, IntoIterator::Into_iter(self.board_content) and self.board_content.into_iter() should be identical identical(as well as Self::into_iter(self.board_content), and ::into_iter(self.board_content) I believe)

  • @saaddahmani1870
    @saaddahmani1870 2 ปีที่แล้ว +1

    Awesome explanation for C# coming developers... from C# developer !!.

  • @sbrugby1
    @sbrugby1 3 ปีที่แล้ว +2

    Strong Christolph Waltz vibes

    • @Raleighthrbub123
      @Raleighthrbub123 2 ปีที่แล้ว

      Well, he's Austrian so that would make sense. Excellent energy. Really commands your attention and makes you hyped (or scared) lol.

    • @peter9477
      @peter9477 2 ปีที่แล้ว

      That feeling when Dr. Schultz is teaching you Rust...

  • @luizchagasjardim
    @luizchagasjardim 3 ปีที่แล้ว +9

    Oh, man. I need to learn German to understand traits? XD
    Just kidding. Awesome talk. I would recomend it to all people looking into learning Rust.

  • @joelmontesdeoca6572
    @joelmontesdeoca6572 2 ปีที่แล้ว

    What a mind blowing talk!

  • @victorfds
    @victorfds 2 ปีที่แล้ว

    The speaker is awesome. 🤓. I really liked the code examples.

  • @JohnPywtorak
    @JohnPywtorak ปีที่แล้ว +1

    Hi great talk, thank you. Small thing at 18:00, not really automatic magic, more fully qualified syntax since default doesn't have a Self receiver as I just learned. It threw me and I didn't understand other than the obvious thing happening. It is like ::default().

  • @erc_io
    @erc_io 2 ปีที่แล้ว +1

    Can someone give me the German at 33:16 when talking about From implying Into?

    • @robert36902
      @robert36902 ปีที่แล้ว +1

      "Eine Fähigkeit auf Basis eine anderen Fähigkeit ableiten" is what it sounds like to me. To derive a trait based on another trait, or something like that.

  • @kamilzielinski504
    @kamilzielinski504 ปีที่แล้ว

    very good examples

  • @i.8530
    @i.8530 2 ปีที่แล้ว

    Great talk, I learned a lot from it!

  • @mario7501
    @mario7501 ปีที่แล้ว

    Great talk! I like to always include the return statement though. It makes code more readable I think.

  • @user-jt7wb3zc1m
    @user-jt7wb3zc1m 2 ปีที่แล้ว

    Cool! Amazing talk! 🦀

  • @func0der
    @func0der 2 ปีที่แล้ว

    Thank you very much for this very clear talk.

  • @СергеичЪФ
    @СергеичЪФ 3 ปีที่แล้ว +2

    Good!

  • @jensen7141
    @jensen7141 3 ปีที่แล้ว +2

    👏👏👏

  • @brogen100
    @brogen100 3 ปีที่แล้ว +3

    I want to double like

  • @nteasushz
    @nteasushz 3 ปีที่แล้ว +2

    🍺

  • @theimmortalsinger3762
    @theimmortalsinger3762 11 หลายเดือนก่อน

    "let me just say one sentence in german so that the whole audience gets it."
    Says it.
    Doesn't translate.
    Wut?

  • @hanyanglee9018
    @hanyanglee9018 7 หลายเดือนก่อน

    42 Comments
    😆

  • @sergesolkatt
    @sergesolkatt ปีที่แล้ว

    ❤️