Closed as not planned
Description
Summary
allow kotlin-style single expression function syntax in form of fn name() = expr
fn hello() -> &'static str = "Hello"
fn add(a: i32, b: i32) -> i32 = a + b
fn rank(n: i32) -> i32 = match n {
1 => 1,
2 | 3 | 4 => 2,
13..=20 => 3,
_ => 4,
}
Advantages
one less brackets improve readability, espcially for functions with single match block.
Disadvantages
being able to do same things in two different way may be confusing.
fn add(a: i32, b: i32) -> i32 = a + b
fn add(a: i32, b: i32) -> i32 { a + b }
Previous Discussion
there was previous discussion on this topic, but the it was mostly about implicit return type. however, that is beyond this RFC's scope.
Metadata
Metadata
Assignees
Labels
No labels