Replies: 2 comments
-
That RngCore impl does not implement Deref or DerefMut for anything that is not a smart pointer, so the C-DEREF guideline has no bearing. But as a downside you should consider that adding this impl would make RngCore-related error messages much worse. Blanket impls (meaning + use std::ops::DerefMut;
trait RngCore {}
+ impl<R: RngCore + ?Sized, T: DerefMut<Target = R>> RngCore for T {}
fn assert_rng_core<T: RngCore>() {}
fn main() {
assert_rng_core::<String>();
} Error message without impl
Error message after adding impl
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently the guidelines say "Only smart pointers implement
Deref
andDerefMut
(C-DEREF)".In this PR in
rand
we are considering using this trick:With the comment
Would this be a good exception to the rule?
Beta Was this translation helpful? Give feedback.
All reactions