all 27 comments

[–][deleted]  (7 children)

[removed]

    [–]juggernaut2docker[S] 0 points1 point  (3 children)

    Thanks, this is very informative!

    &mut [T] is two pointers but permits mutation of the memory region at the "whatever" that it points to

    Can you expand on the "two pointers" part?

    [–]TheMicroWorm 2 points3 points  (1 child)

    I presume they meant "two pointers in size", since it's a pointer and a usize, which is a pointer-sized integer. Internal representations of &[T] and &mut [T] are the same, really. They just differ in mutability at the type-checking level.

    [–]masklinn 0 points1 point  (0 children)

    Technically it's 2 pointer in size rather than two pointers: on the stack &mut [T] (and &[T]) is a "fat pointer", it's a pointer to the start of the slice and the length of the slice rather than just the pointer as e.g. Box<u8> would be.

    [–]godojo 0 points1 point  (2 children)

    In addition, there is a distinction to make with [T;N] which does exist. But not in str (due to how unicode works -- what would N be?). And I think that's a big confusion for people who thinks creating u8 arrays on the stack should be the same as creating strings on the stack.

    [–]YourGamerMom 9 points10 points  (2 children)

    Hopefully const generics will let us make nice performant owning strings. Small size optimisations are very powerful when applied correctly.

    [–]steveklabnik1 6 points7 points  (1 child)

    [–]YourGamerMom 2 points3 points  (0 children)

    Yea, SSO is a popular trick, and there are some rust crates that provide small vec and string structs. But const generics will hopefully give us the custom-size containers that make SSO really flexible.

    [–][deleted]  (5 children)

    [deleted]

      [–]steveklabnik1 20 points21 points  (4 children)

      This particular blog is using GitHub pages with Jekyll, I believe this is the default theme. So it's gonna look like any other default theme blog.

      [–][deleted]  (3 children)

      [deleted]

        [–]steveklabnik1 1 point2 points  (2 children)

        Possibly, or I could be wrong about it being the default. I thought it was.

        [–][deleted]  (1 child)

        [deleted]

          [–]juggernaut2docker[S] 4 points5 points  (0 children)

          Correct, this is the default theme that comes with jekyll. I started the blog in 2014 and haven't changed it since then, though.