-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as duplicate of#3369
Description
I'm not a good writer, so let's skip to examples right now.
Before:
mod rfc {
type Size = (usize, usize);
#[derive(Default)]
struct Window {
pub title: String,
pub size: Size,
pub close_when_requested: bool,
}
// ⚙️ Just regular Rust, nothing inconvenient
fn make_diagnostic_window(size: Size) -> Window {
Window {
size,
title: "Diagnostic window".into(),
..Default::default()
}
}
}After:
mod rfc {
type Size = (usize, usize);
#[derive(Default)]
struct Window {
pub title: String,
pub size: Size,
pub close_when_requested: bool,
}
// ⚡️ Shorthand proposal
fn make_diagnostic_window(size: Size) => Window {
size,
title: "Diagnostic window".into(),
..Default::default()
}
// Still an option
fn old_fashioned_way(size: Size) -> Window {
Window {
size,
title: "Diagnostic window".into(),
..Default::default()
}
}
}As average language user, I'm not sure about all possible caveats but in my opinion this syntax looks appropriate enough. Simple, clean, fast to write & maintain.
Metadata
Metadata
Assignees
Labels
No labels