RFC link; Tracking issue (not for discussion, just tracking): rust-lang/rust#132162
In short:
#[derive(Default)]
struct Pet {
name: Option<String>, // impl Default for Pet will use Default::default() for name
age: i128 = 42, // impl Default for Pet will use the literal 42 for age
}
// This works and produces:
// `Pet { name: Some(""), age: 42 }`
let _ = Pet { name: Some(String::new()), .. }
// Compilation error: `name` needs to be specified
let _ = Pet { .. }
Desirable SemVer major, deny by default lints:
Desirable SemVer major, warn by default lints:
Progress:
RFC link; Tracking issue (not for discussion, just tracking): rust-lang/rust#132162
In short:
Desirable SemVer major, deny by default lints:
{ .. }syntax now requires supplying a value for that field.Default, sinceDefaultdoesn't matter{ .. }-style construction.Desirable SemVer major, warn by default lints:
Default::default()to a different, explicitly-specified valueimpl Defaulton the struct/enum is derived (hand-impls might not use theDefault::default()for the field!), and also need to determine whatDefault::default()would return for the field's type.Default::default()isn'tconstin general, so we'd probably have to hardcode defaults for common built-in types.Progress:
trustfall-rustdoc-adapter