Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 5551b82

Browse files
committed
Boxify the async callback closures
Resolves issue #18.
1 parent 5419fe1 commit 5551b82

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

fauxgen/gio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl File {
341341
pub fn read_async<F>(&mut self,
342342
io_priority: types::gint,
343343
cancellable: Option<&mut Cancellable>,
344-
callback: F)
344+
callback: Box<F>)
345345
where F : FnOnce(&mut gobject::Object, &mut AsyncResult) + Send
346346
{
347347
unsafe {

src/callback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ pub struct AsyncCallback<Args, Ret> {
3838

3939
impl<Args, Ret> AsyncCallback<Args, Ret> {
4040

41-
pub fn new<F>(func: F) -> AsyncCallback<Args, Ret>
41+
pub fn new<F>(func: Box<F>) -> AsyncCallback<Args, Ret>
4242
where F: FnOnce<Args, Ret> + Send
4343
{
44-
AsyncCallback { closure: box func }
44+
AsyncCallback { closure: func }
4545
}
4646

4747
pub fn invoke(self, args: Args) -> Ret {

tests/test-gio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn async() {
7272
run_on_mainloop(|mut mainloop| {
7373
let mut f = File::new_for_path("/dev/null");
7474
f.read_async(0, None,
75-
move |: obj, res| {
75+
box move |obj, res| {
7676
let f: &mut File = object::cast_mut(obj);
7777
match f.read_finish(res) {
7878
Ok(_) => {}
@@ -88,7 +88,7 @@ fn error_to_domain() {
8888
run_on_mainloop(|mut mainloop| {
8989
let mut f = File::new_for_path("./does-not-exist");
9090
f.read_async(0, None,
91-
move |: obj, res| {
91+
box move |obj, res| {
9292
let f: &mut File = object::cast_mut(obj);
9393
match f.read_finish(res) {
9494
Ok(_) => { unreachable!() }
@@ -114,7 +114,7 @@ fn error_match_partial_eq() {
114114
run_on_mainloop(|mut mainloop| {
115115
let mut f = File::new_for_path("./does-not-exist");
116116
f.read_async(0, None,
117-
move |: obj, res| {
117+
box move |obj, res| {
118118
let f: &mut File = object::cast_mut(obj);
119119
match f.read_finish(res) {
120120
Ok(_) => { unreachable!() }

0 commit comments

Comments
 (0)