Ancestors

Written by Esteban Küber :rust: on 2024-12-10 at 16:21

I can't wait to see how people use default field values in #Rust!

It felt like an eternity to land this (specially if we count the years of discussion before the, I believe, 3rd RFC was accepted), but as of next nightly you will be able to write

struct Foo {

bar: Type = Type::const_method(),

}

Foo { .. } // implicit bar: Type::const_method() call

The main difference between https://github.com/rust-lang/rust/pull/129514 and derive(Default) is that the latter doesn't support having mandatory fields.

[#]RustLang

=> View attached media

=> More informations about this toot | More toots from ekuber@hachyderm.io

Written by Esteban Küber :rust: on 2024-12-11 at 17:43

Default fields values are now live on nightly #Rust! Go wild and report bugs 😃

[#]RustLang

=> View attached media | View attached media

=> More informations about this toot | More toots from ekuber@hachyderm.io

Written by Jacob Pratt on 2024-12-11 at 23:47

@ekuber Prefer issues be opened as usual, DM, or something else?

=> More informations about this toot | More toots from jhpratt@mastodon.social

Toot

Written by Esteban Küber :rust: on 2024-12-12 at 00:15

@jhpratt tickets on the issue tracker referencing the tracking issue and tagged as F-default_field_values would be best

=> More informations about this toot | More toots from ekuber@hachyderm.io

Descendants

Written by Jacob Pratt on 2024-12-14 at 05:09

@ekuber Took maybe an hour to figure out how to minimize it, but the first bug for the feature is now open :)

https://github.com/rust-lang/rust/issues/134298

=> More informations about this toot | More toots from jhpratt@mastodon.social

Written by Esteban Küber :rust: on 2024-12-14 at 05:39

@jhpratt it looks like I need to extend what the Well formed check does for structs with defaults. You would think that they stretch without a default would also error.

This is a nice milestone!

=> More informations about this toot | More toots from ekuber@hachyderm.io

Written by Jacob Pratt on 2024-12-14 at 05:49

@ekuber it's heavily minimized from real-world code in the time crate (with the addition of default values). Inference is a wonderful thing!

=> More informations about this toot | More toots from jhpratt@mastodon.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113636967486621997
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
322.102431 milliseconds
Gemini-to-HTML Time
3.621305 milliseconds

This content has been proxied by September (3851b).