Created
February 11, 2024 05:27
-
-
Save oconnor663/c648f3aa6fcd9662e130c0222110c3e6 to your computer and use it in GitHub Desktop.
invariant lifetimes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn foo<'left, 'right>(_: &mut &'left i32, _: &mut &'right i32) | |
where | |
'left: 'right, | |
{ | |
} | |
// fn foo<'both>(_: &mut &'both i32, _: &mut &'both i32) {} | |
fn main() { | |
let a = 42; | |
let mut a = &a; | |
{ | |
let b = 43; | |
let mut b = &b; | |
foo(&mut a, &mut b); | |
} | |
{ | |
let b = 44; | |
let mut b = &b; | |
foo(&mut a, &mut b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment