Skip to content

Commit ba7070e

Browse files
committed
Fix strange usages of &mut *
1 parent 88ea8dc commit ba7070e

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

src/common.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,7 @@ impl<T> RawReceiver<T> {
499499
500500
*/
501501
pub fn invoke(&self, x: Arc<T>) {
502-
let func = &mut *self.func.lock().unwrap();
503-
(func)(x);
502+
(self.func.lock().unwrap())(x);
504503
}
505504
}
506505

@@ -540,8 +539,8 @@ impl RawFunc {
540539
Invoke the `FnMut`.
541540
*/
542541
pub fn invoke(&self) {
543-
let func = &mut *self.func.lock().unwrap();
544-
(func)();
542+
// let func = &mut *self.func.lock().unwrap();
543+
(self.func.lock().unwrap())();
545544
}
546545
}
547546

src/cor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ impl<RETURN: Send + Sync + 'static, RECEIVE: Send + Sync + 'static> Cor<RETURN,
445445
_effect = this.lock().unwrap().effect.clone();
446446
}
447447

448-
let effect = &mut *_effect.lock().unwrap();
449-
(effect)(this.clone());
448+
(_effect.lock().unwrap())(this.clone());
450449
}
451450

452451
{

src/monadio.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,7 @@ impl<Y: 'static + Send + Sync> MonadIO<Y> {
107107
let mut _effect = self.effect.clone();
108108

109109
MonadIO::new_with_handlers(
110-
move || {
111-
let _func = _func.clone();
112-
let func = &mut *_func.lock().unwrap();
113-
114-
let effect = &mut *_effect.lock().unwrap();
115-
116-
(func)((effect)())
117-
},
110+
move || (_func.lock().unwrap())((_effect.lock().unwrap())()),
118111
self.ob_handler.clone(),
119112
self.sub_handler.clone(),
120113
)
@@ -125,10 +118,7 @@ impl<Y: 'static + Send + Sync> MonadIO<Y> {
125118
) -> MonadIO<Z> {
126119
let mut _func = Arc::new(Mutex::new(func));
127120

128-
self.map(move |y: Y| {
129-
let mut func = _func.lock().unwrap();
130-
((func)(y).effect.lock().unwrap())()
131-
})
121+
self.map(move |y: Y| ((_func.lock().unwrap())(y).effect.lock().unwrap())())
132122
}
133123
pub fn subscribe(&self, s: Arc<impl Subscription<Y>>) {
134124
let mut _effect = self.effect.clone();
@@ -210,8 +200,7 @@ fn test_monadio_new() {
210200
let monadio_simple = MonadIO::just(3);
211201
// let mut monadio_simple = MonadIO::just(3);
212202
{
213-
let effect = &mut *monadio_simple.effect.lock().unwrap();
214-
assert_eq!(3, (effect)());
203+
assert_eq!(3, (monadio_simple.effect.lock().unwrap())());
215204
}
216205
let monadio_simple_map = monadio_simple.map(|x| x * 3);
217206

0 commit comments

Comments
 (0)