Description
Tracking Issue: #109417
Hi, I'm new so let me know if this is not the right forum for this :), the tracking issue noted that it was not for discussion and that people should open up a separate issue.
I had an idea for a more consistent syntax for Return Type Notation. My thought process is as follows:
Given that we already have traits that auto-implement for all functions (FnOnce
, Fn
, FnMut
), which all contain the associated type FnOnce::Output
, why not just allow the ability to impose constraints on that associated type as a way to name the output of a function?
For Example:
// Current syntax
trait It {
fn iter(&self) -> impl Iterator<Item = u32>;
}
fn twice<I: It<iter(): Clone>>(i: I) {}
// new syntax idea:
fn twice<I: It>(i: I)
where
<I::iter as Fn>::Output: Clone
{}
// could even be shortened further:
fn twice<I: It<iter::Output: Clone>>(i: I) {}
Came up with this idea while watching Jon Gjengset's lecture about impl Traits, so I don't quite understand all the minutiae of the feature, only that this is a problem and it seems to require syntax changes. Is this idea semantically inconsistent? decent but needs modification? totally awesome? What you all think?