From 296c88c49cbe72aea9d3726147a9436902b3446b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 21 Apr 2017 21:25:10 -0500 Subject: [PATCH] add `borrow_mut` to Local --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 910635f341..a0c8a3bac3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -407,6 +407,14 @@ impl Local { pub fn borrow<'task>(&'static self, _task: &'task TASK) -> &'task T { unsafe { &*self.data.get() } } + + /// Mutably borrows the task local data for the duration of the task + pub fn borrow_mut<'task>( + &'static self, + _task: &'task mut TASK, + ) -> &'task mut T { + unsafe { &mut *self.data.get() } + } } unsafe impl Sync for Local {}