Skip to content

Instantly share code, notes, and snippets.

@oconnor663
Created February 11, 2024 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oconnor663/c648f3aa6fcd9662e130c0222110c3e6 to your computer and use it in GitHub Desktop.
Save oconnor663/c648f3aa6fcd9662e130c0222110c3e6 to your computer and use it in GitHub Desktop.
invariant lifetimes
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