]> git.lizzy.rs Git - rust.git/commitdiff
Remove redundant lifetime bound from `impl Borrow for Cow`
authorFrank Steffahn <frank.steffahn@stu.uni-kiel.de>
Thu, 21 Jul 2022 23:35:39 +0000 (01:35 +0200)
committerFrank Steffahn <frank.steffahn@stu.uni-kiel.de>
Thu, 21 Jul 2022 23:35:39 +0000 (01:35 +0200)
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 ^^

library/alloc/src/borrow.rs

index 904a53bb4acc73418e1f3431cba56f4b29057994..83a1385599bec8c70c79d54fdd67f154d238f9fa 100644 (file)
@@ -21,7 +21,6 @@
 impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
 where
     B: ToOwned,
-    <B as ToOwned>::Owned: 'a,
 {
     fn borrow(&self) -> &B {
         &**self