Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ImmutableCovariant;
- impl<'s> ImmutableCovariant {
- fn smaller<'a>(v: &'s &'a i32) {
- }
- fn bigger(v: &'s &'static i32) {
- Self::smaller(v);
- }
- }
- struct ImmutableContravariantFAILS;
- impl<'s> ImmutableContravariantFAILS {
- fn smaller<'a>(v: &'s &'a i32) {
- Self::bigger(v);
- }
- fn bigger(v: &'s &'static i32) {
- }
- }
- // This should fail!
- struct MutableCovariantSUCCEEDS;
- impl<'s> MutableCovariantSUCCEEDS {
- fn smaller<'a>(v: &'s mut &'a i32) {
- }
- fn bigger(v: &'s mut &'static i32) {
- Self::smaller(v);
- }
- }
- struct MutableContravariantFAILS;
- impl<'s> MutableContravariantFAILS {
- fn smaller<'a>(v: &'s mut &'a i32) {
- Self::bigger(v);
- }
- fn bigger(v: &'s mut &'static i32) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement