Skip to content

Commit 9333af9

Browse files
committed
refactor(cocoa): use Cell
1 parent 32dd49f commit 9333af9

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/ui/mac/filebox.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, path::PathBuf, rc::Rc};
1+
use std::{cell::Cell, path::PathBuf, rc::Rc};
22

33
use block2::StackBlock;
44
use objc2::rc::Retained;
@@ -184,10 +184,9 @@ async unsafe fn filebox(
184184

185185
let res = if let Some(parent) = &parent {
186186
let (tx, rx) = local_sync::oneshot::channel();
187-
let tx = Rc::new(RefCell::new(Some(tx)));
187+
let tx = Rc::new(Cell::new(Some(tx)));
188188
let block = StackBlock::new(move |res| {
189-
tx.borrow_mut()
190-
.take()
189+
tx.take()
191190
.expect("the handler should only be called once")
192191
.send(res)
193192
.ok();

src/ui/mac/msgbox.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, rc::Rc};
1+
use std::{cell::Cell, rc::Rc};
22

33
use block2::StackBlock;
44
use compio::buf::arrayvec::ArrayVec;
@@ -82,10 +82,9 @@ async fn msgbox_custom(
8282

8383
if let Some(parent) = &parent {
8484
let (tx, rx) = local_sync::oneshot::channel();
85-
let tx = Rc::new(RefCell::new(Some(tx)));
85+
let tx = Rc::new(Cell::new(Some(tx)));
8686
let block = StackBlock::new(move |res| {
87-
tx.borrow_mut()
88-
.take()
87+
tx.take()
8988
.expect("the handler should only be called once")
9089
.send(responses[(res - NSAlertFirstButtonReturn) as usize])
9190
.ok();

0 commit comments

Comments
 (0)