From 8547ef73f39ec7ca533461284f5cd779db747b76 Mon Sep 17 00:00:00 2001 From: pln Date: Fri, 21 Apr 2017 14:56:15 +0200 Subject: [PATCH] claim_mut with Rust borrow check --- src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e9b1a24cbd..91c10eeb5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -434,7 +434,6 @@ where /// Nem attempt use core::cell::RefCell; -use core::cell::RefMut; //use core::borrow::BorrowMut; /// A resource @@ -556,17 +555,17 @@ impl ResRef> { basepri_max::write(::hw()); barrier!(); - let r: &RefCell = &*self.data.get(); - let rr: RefCell = *r; - let mut rm: RefMut = rr.borrow_mut(); - let mut t: T = *rm; - let ret = f(&mut t, &C { _marker: PhantomData }); + let a = &*self.data.get(); + let mut am = a.borrow_mut(); + let ret = f(&mut am, &C { _marker: PhantomData }); barrier!(); basepri::write(old_basepri); ret } else { - panic!(""); + let a = &*self.data.get(); + let mut am = a.borrow_mut(); + f(&mut am, &C { _marker: PhantomData }) } } }