Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Apoplexy@lemmy.world to Rust@programming.devEnglish · 7 months ago

Tracking issue for RFC 3681: Default field values · Issue #132162 · rust-lang/rust

github.com

external-link
message-square
6
fedilink
29
external-link

Tracking issue for RFC 3681: Default field values · Issue #132162 · rust-lang/rust

github.com

Apoplexy@lemmy.world to Rust@programming.devEnglish · 7 months ago
message-square
6
fedilink
This is a tracking issue for the RFC "3681" (rust-lang/rfcs#3681). The feature gate for the issue is #![feature(default_field_values)]. Allow struct definitions to provide default values for indivi...
alert-triangle
You must log in or # to comment.
  • robinm@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    7 months ago

    It’s really nice to see this RFC progress

  • snaggen@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    7 months ago

    I think this would be a nice improvement to reduce boiler plate.

  • SorteKanin@feddit.dk
    link
    fedilink
    arrow-up
    4
    ·
    7 months ago

    Hmmm… I guess I don’t see why not?

  • d_k_bo@feddit.org
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    7 months ago

    This is really great and would solve the problem that led me to create constructor-lite.

    With this RFC, its usage could be replaced with

    #[derive(Debug, PartialEq)]
    struct Movie {
        title: String,
        year: Option<u16> = None,
    }
    
    assert_eq!(
        Movie { title: "Star Wars".to_owned(), .. },
        Movie { title: "Star Wars".to_owned(), year: None },
    )
    
    
    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      2
      ·
      7 months ago

      Think you would need Movie { title: "Star Wars".to_owned(), .. }, the .. is mandatory.

      • d_k_bo@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        Thanks, that was an oversight on my part.

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: [email protected]

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

Wormhole

[email protected]

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.

  • 11 users / day
  • 38 users / week
  • 363 users / month
  • 2.73K users / 6 months
  • 1 local subscriber
  • 7.13K subscribers
  • 934 Posts
  • 4.34K Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • EdTheLegendary@programming.dev
  • kahnclusions@programming.dev
  • torcherist@programming.dev
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org