-
-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax Sized
requirements for blanket impls
#1593
Conversation
Oh wait, I feel dumb, there's already #1592. But I add the |
I don't believe this a breaking change either, and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than UnwrapErr
this looks fine... though possibly not very useful.
I release now there is something missing from #1589: reborrow support. Basically this method (see the RFC issue):
/// Reborrow with a new lifetime
///
/// Rust allows references like `&T` or `&mut T` to be "reborrowed" through
/// coercion: essentially, the pointer is copied under a new, shorter, lifetime.
/// Until rfcs#1403 lands, reborrows on user types require a method call.
#[inline(always)]
pub fn re<'b>(&'b mut self) -> UnwrapMut<'b, R>
where
'r: 'b,
{
UnwrapMut(self.0)
}
We may also (or instead) want to publicly export UnwrapErr
and UnwrapMut
from rand
.
@newpavlov thoughts?
Applied RFCs
My use case is passing an external RNG through a dyn-safe trait API. Then I might have a |
This looks fine to me. Could you add tests which would cover your use case? |
Added a test for |
Yes, I think it's worth to have them to prevent potential future regressions. |
Added the remaining tests |
Relaxes
Sized
bound on blanket impls forTryRngCore
,TryCryptoRng
,UnwrapErr
, andUnwrapMut
.This came up when trying to pass a
RngCore + ?Sized
-bound argument to a method from a third-party library requiringTryRngCore + ?Sized
.I think this is not a breaking change, but not 100% sure.