claim_mut with Rust borrow check

This commit is contained in:
pln 2017-04-21 14:56:15 +02:00
parent 9ede9215c2
commit 8547ef73f3

View file

@ -434,7 +434,6 @@ where
/// Nem attempt /// Nem attempt
use core::cell::RefCell; use core::cell::RefCell;
use core::cell::RefMut;
//use core::borrow::BorrowMut; //use core::borrow::BorrowMut;
/// A resource /// A resource
@ -556,17 +555,17 @@ impl<T, CEILING> ResRef<T, C<CEILING>> {
basepri_max::write(<CEILING>::hw()); basepri_max::write(<CEILING>::hw());
barrier!(); barrier!();
let r: &RefCell<T> = &*self.data.get(); let a = &*self.data.get();
let rr: RefCell<T> = *r; let mut am = a.borrow_mut();
let mut rm: RefMut<T> = rr.borrow_mut(); let ret = f(&mut am, &C { _marker: PhantomData });
let mut t: T = *rm;
let ret = f(&mut t, &C { _marker: PhantomData });
barrier!(); barrier!();
basepri::write(old_basepri); basepri::write(old_basepri);
ret ret
} else { } else {
panic!(""); let a = &*self.data.get();
let mut am = a.borrow_mut();
f(&mut am, &C { _marker: PhantomData })
} }
} }
} }