mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +01:00
chore(lua): style
This commit is contained in:
parent
45864e19f6
commit
d66b25deb4
4 changed files with 22 additions and 37 deletions
|
@ -12,10 +12,9 @@ impl LuaUserData for CodempBufferController {
|
|||
Ok(format!("{:?}", this))
|
||||
});
|
||||
|
||||
methods.add_method("send", |_, this, (change,): (CodempTextChange,)| {
|
||||
this.send(change)?;
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("send", |_, this, (change,): (CodempTextChange,)|
|
||||
Ok(this.send(change)?)
|
||||
);
|
||||
|
||||
methods.add_method(
|
||||
"try_recv",
|
||||
|
@ -29,16 +28,12 @@ impl LuaUserData for CodempBufferController {
|
|||
|_, this, ()| a_sync! { this => this.content().await? },
|
||||
);
|
||||
|
||||
methods.add_method("clear_callback", |_, this, ()| {
|
||||
this.clear_callback();
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)| {
|
||||
this.callback(move |controller: CodempBufferController| {
|
||||
methods.add_method("clear_callback", |_, this, ()| Ok(this.clear_callback()));
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)|
|
||||
Ok(this.callback(move |controller: CodempBufferController|
|
||||
super::ext::callback().invoke(cb.clone(), controller)
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@ impl LuaUserData for CodempCursorController {
|
|||
});
|
||||
|
||||
methods.add_method("send", |_, this, (cursor,): (CodempCursor,)| {
|
||||
this.send(cursor)?;
|
||||
Ok(())
|
||||
Ok(this.send(cursor)?)
|
||||
});
|
||||
methods.add_method(
|
||||
"try_recv",
|
||||
|
@ -23,16 +22,12 @@ impl LuaUserData for CodempCursorController {
|
|||
methods.add_method("recv", |_, this, ()| a_sync! { this => this.recv().await? });
|
||||
methods.add_method("poll", |_, this, ()| a_sync! { this => this.poll().await? });
|
||||
|
||||
methods.add_method("clear_callback", |_, this, ()| {
|
||||
this.clear_callback();
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)| {
|
||||
this.callback(move |controller: CodempCursorController| {
|
||||
methods.add_method("clear_callback", |_, this, ()| Ok(this.clear_callback()));
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)|
|
||||
Ok(this.callback(move |controller: CodempCursorController|
|
||||
super::ext::callback().invoke(cb.clone(), controller)
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,7 @@ impl LuaUserData for Promise {
|
|||
});
|
||||
methods.add_method_mut("cancel", |_, this, ()| match this.0.take() {
|
||||
None => Err(LuaError::runtime("Promise already awaited")),
|
||||
Some(x) => {
|
||||
x.abort();
|
||||
Ok(())
|
||||
}
|
||||
Some(x) => Ok(x.abort()),
|
||||
});
|
||||
methods.add_method_mut("and_then", |_, this, (cb,): (LuaFunction,)| {
|
||||
match this.0.take() {
|
||||
|
|
|
@ -60,17 +60,15 @@ impl LuaUserData for CodempWorkspace {
|
|||
|
||||
methods.add_method("poll", |_, this, ()| a_sync! { this => this.poll().await? });
|
||||
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)| {
|
||||
this.callback(move |controller: CodempWorkspace| {
|
||||
methods.add_method("callback", |_, this, (cb,): (LuaFunction,)|
|
||||
Ok(this.callback(move |controller: CodempWorkspace|
|
||||
super::ext::callback().invoke(cb.clone(), controller)
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
))
|
||||
);
|
||||
|
||||
methods.add_method("clear_callbacl", |_, this, ()| {
|
||||
this.clear_callback();
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("clear_callbacl", |_, this, ()|
|
||||
Ok(this.clear_callback())
|
||||
);
|
||||
}
|
||||
|
||||
fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F) {
|
||||
|
|
Loading…
Reference in a new issue