docs for Traits get duplicated because of different types
f32 for example essentially supports traits like Add which have multiple copies which aren't duplicates but seem repetitive because they are essentially very similar:
Currently:
impl Add<f32> for f32
type Output = f32
fn add(self, other: f32) -> f32
impl<'a> Add<f32> for &'a f32
type Output = f32::Output
fn add(self, other: f32) -> f32::Output
impl<'a> Add<&'a f32> for f32
type Output = f32::Output
fn add(self, other: &'a f32) -> f32::Output
impl<'a, 'b> Add<&'a f32> for &'b f32
type Output = f32::Output
fn add(self, other: &'a f32) -> f32::Output
It would be very nice if these could be combined so the repetition is less drastic. I've only come up with 2 options so far but maybe there are more.
Option A:
This is tricky to improve because all are different. One course would be to collapse all but the last by default which would make it look like the following block. This would also aid https://github.com/rust-lang/rust/issues/21660 . This makes all the types clear but only shows one method because all the methods will be the same.
+impl Add<f32> for f32
+impl<'a> Add<f32> for &'a f32
+impl<'a> Add<&'a f32> for f32
-impl<'a, 'b> Add<&'a f32> for &'b f32
type Output = f32::Output
fn add(self, other: &'a f32) -> f32::Output
Option B:
Use some type of shorthand to include all options (like globbing). This should expand to specifics if desired I suppose.
impl<.*> Add<.* f32> for .* f32
type Output = f32.*
fn add(self, other: .* f32) -> f32::Output
Option A looks the most practical. I'm trying to think of a better way to include only one but still allow the specifics to be examined but haven't come up with any better ideas.
This may interfere with https://github.com/rust-lang/rust/issues/24558 if it was ever implemented though it may be a better idea.
cc @Gankro
mdinger at 2015-04-18 16:28:54
cc @alexcrichton
Aria Desires at 2015-04-18 17:09:10
Triage: no changes. I'm slightly wary of reducing this duplication, because well, they are in fact different types, but option A doesn't seem too bad...
Steve Klabnik at 2016-06-06 21:26:19
Triage: i feel the same as my last comment.
Steve Klabnik at 2018-10-31 14:03:40