The Slice Type - Rust

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

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

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

    Thank you for the effort. Please increase the resolution on the code screen. Thx!!!

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

      It took me a while, but I fixed it on later videos - Thanks! (:

  • @thesilenthack
    @thesilenthack 4 ปีที่แล้ว

    Thank you for your videos! They are very helpful!!! :)

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

    »&s[..]« is equal to »&s« ? I would guess. Thanks for the video

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

      In terms of its' value, yes ~ In terms of its' type, no. For example: if s is "M. Otto".𝚝𝚘_𝚜𝚝𝚛𝚒𝚗𝚐() (i.e., of type String), in this case, &s is of type &String, and &s[..] is of type &str.

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

      @@danlogs Ah, that makes sense. I bet this is quite a common rust newbie mistake.

  • @syedabdulbasit4466
    @syedabdulbasit4466 4 ปีที่แล้ว

    If we skip the slice type in rust then what would be the impact? The slice type is important or not, if we just skip that slice topic

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

      I would suggest that you follow along in the order the videos are set in the playlist without skipping! I'm following the same order as The Rust Programming Language book and I don't think any of the info in there is "extra" ~ Hope that helps!

    • @syedabdulbasit4466
      @syedabdulbasit4466 4 ปีที่แล้ว

      @@danlogs ok

  • @pedantic79
    @pedantic79 5 ปีที่แล้ว

    You didn't cover the other slice type. &[T]

    • @danlogs
      @danlogs  5 ปีที่แล้ว

      At around 11:41, I said that slices aren't constrained to just strings and gave an example of slicing an array of i32s. In that case, our slice is of type &[i32] which would fit the generic of &[T].
      I didn't explicitly mention generics just because I'm holding that concept for full discussion in a later video.
      Thank you so much for your comment!

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

      Heyo! ~ I finally made a video talking about &[T], here: th-cam.com/video/vzk5LvFHbrQ/w-d-xo.html ッ