Source/docs difference with trait bounds

I've found a somewhat strange element in generated docs. Of course this is not something critical, but it looks a bit confusing.

First, here's the definition of Cow in source code:

pub enum Cow<'a, B: ?Sized + 'a>
    where B: ToOwned
{
    // ....
}

We can see three bounds on B, two - in the generic parameters list, one - in where clause.
Now, how it looks like in docs:

pub enum Cow<'a, B> 
where
    B: 'a + ToOwned + 'a + ?Sized, 
 {
     // ....
 }

The most confusing thing here is the duplicated lifetime bound - I can't really understand where it is coming from. Anyway, even with the duplication aside, is this difference intentional?

I cannot know what the docs team reason for doing it like that is, I can only speculate. But most likely the reason is that, even if both forms are equivalent, bound wise,

enum/trait/struct Name<'a, B> 
where
    B: ToOwned + ?Sized + 'a, 
 {
     // ....
 }

is the closest to a "standard/normalised form".

The double 'a bound, however, looks like a bug :smiley:


Aside: I wish the docs had an option to show elided lifetimes, at the very least in "paths". For instance, going

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.