Created
July 14, 2021 17:41
-
-
Save godmar/94a173259963ceb56191c49dbf2eda0a to your computer and use it in GitHub Desktop.
test case that triggers mutable_borrow_reservation_conflict
This file contains 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
use intrusive_collections::intrusive_adapter; | |
use intrusive_collections::{LinkedList, LinkedListLink}; | |
// A simple struct containing an instrusive link and a value | |
struct Test { | |
link: LinkedListLink, | |
value: isize, | |
} | |
intrusive_adapter!(TestAdapter = Box<Test>: Test { link: LinkedListLink }); | |
fn main() { | |
let mut l = LinkedList::new(TestAdapter::new()); | |
const L: isize = 0; | |
const H: isize = 10; | |
for i in L..H { | |
let a = Box::new(Test { | |
link: LinkedListLink::new(), | |
value: i, | |
}); | |
l.push_front(a); | |
} | |
for p in l.iter() { | |
print!("{} ", p.value); | |
} | |
println!(); | |
// remove next-to-last element and insert at the front | |
let mut a = l.back(); | |
a.move_prev(); | |
let a = a.get().unwrap(); | |
unsafe { | |
let mut c = l.cursor_mut_from_ptr(a as *const Test); | |
let last = c.remove().unwrap(); | |
l.push_front(last); | |
} | |
/* | |
let a = l.pop_back().unwrap(); | |
l.push_front(a); | |
*/ | |
for p in l.iter() { | |
print!("{} ", p.value); | |
} | |
println!(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment