Skip to content

Commit

Permalink
Remove redundant lifetime bound from impl Borrow for Cow
Browse files Browse the repository at this point in the history
The lifetime bound `B::Owned: 'a` is redundant and doesn't make a difference,
because `Cow<'a, B>` comes with an implicit `B: 'a`, and associated types
will outlive lifetimes outlived by the `Self` type (and all the trait's
generic parameters, of which there are none in this case), so the implicit `B: 'a`
implies `B::Owned: 'a` anyway.

The explicit lifetime bound here does however end up in documentation,
and that's confusing in my opinion, so let's remove it ^^
  • Loading branch information
steffahn committed Jul 21, 2022
1 parent 62b272d commit c03d10c
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use Cow::*;
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
where
B: ToOwned,
<B as ToOwned>::Owned: 'a,
{
fn borrow(&self) -> &B {
&**self
Expand Down

0 comments on commit c03d10c

Please sign in to comment.