Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
SorteKanin ( SorteKanin@feddit.dk )  to Rust@programming.dev · 4 days ago

Announcing Rust 1.99.0 | Rust Blog

blog.rust-lang.org

external-link
message-square
8
link
fedilink
28
external-link

Announcing Rust 1.99.0 | Rust Blog

blog.rust-lang.org

SorteKanin ( SorteKanin@feddit.dk )  to Rust@programming.dev · 4 days ago
message-square
8
link
fedilink
Empowering everyone to build reliable and efficient software.
alert-triangle
You must log in or # to comment.
  • ExperimentalGuy ( ExperimentalGuy@programming.dev ) 
    link
    fedilink
    arrow-up
    6
    ·
    4 days ago

    Stable variadic functions is cool AF!

  • TehPers ( TehPers@beehaw.org ) 
    link
    fedilink
    English
    arrow-up
    3
    ·
    4 days ago

    The extern variadic functions are pretty cool. What I’m actually most excited about is what just moved to beta, though. In particular, stabilization of both Allocator and ! are now in beta.

  • arendjr ( arendjr@programming.dev ) 
    link
    fedilink
    arrow-up
    2
    ·
    4 days ago

    Vec::into_parts() returns a NonNull pointer, but isn’t the pointer allowed to be null if the vector is empty? I would expect that this method should be able to return a null pointer, but I’m probably missing something…

    • BB_C ( BB_C@programming.dev ) 
      link
      fedilink
      arrow-up
      2
      ·
      4 days ago

      To add to the other answers. Usually, the easiest way to answer such questions is to click on source. Then in this case, you would immediately see this comment:

      // SAFETY: A `Vec` always has a non-null pointer.
      
    • SorteKanin ( SorteKanin@feddit.dk ) OP
      link
      fedilink
      arrow-up
      2
      ·
      4 days ago

      It’s a good question. I believe Vec uses a near-zero pointer but not actually a null pointer for an empty Vec. I think part of the reason is that it makes for better optimisation of Option<Vec<T>> which can then have the same size as Vec<T> with the pointer being null signifying None.

      Another big reason is that references are guaranteed not to be null and you can get a &[T] from an empty vec and that reference can’t be null. Even in a non empty vec you need to consider this if T is zero sized.

      • arendjr ( arendjr@programming.dev ) 
        link
        fedilink
        arrow-up
        2
        ·
        4 days ago

        Ah yes, that makes sense. Curious what it points to then when empty…

        • fil ( fil@programming.dev ) 
          link
          fedilink
          arrow-up
          2
          ·
          4 days ago

          Vec::<u8>::new().as_ptr() = 0x0000000000000001

          playground

        • SorteKanin ( SorteKanin@feddit.dk ) OP
          link
          fedilink
          arrow-up
          2
          ·
          4 days ago

          I looked it up, it’s a pointer equal to the alignment of the type. So usually some small power of two.

Rust@programming.dev

rust@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !rust@programming.dev

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits
  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 85 users / week
  • 282 users / month
  • 764 users / 6 months
  • 118 local subscribers
  • 8.31K subscribers
  • 1.27K Posts
  • 3.74K Comments
  • Modlog
  • mods:
  • snowe ( snowe@programming.dev ) 
  • Ategon ( Ategon@programming.dev ) 
  • EdTheLegendary ( EdTheLegendary@programming.dev ) 
  • torcherist ( torcherist@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code