-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more utility functions around modules and exports #3937
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3937 +/- ##
==========================================
+ Coverage 47.24% 51.62% +4.37%
==========================================
Files 476 468 -8
Lines 46892 44999 -1893
==========================================
+ Hits 22154 23230 +1076
+ Misses 24738 21769 -2969 ☔ View full report in Codecov by Sentry. |
core/engine/src/module/mod.rs
Outdated
/// This combines two operations that are often done together into a simpler | ||
/// version. If you need more control over the execution, use [`load_link_evaluate`] | ||
/// and [`Context::run_jobs`] separately. | ||
pub fn load_link_evaluate_and_run_jobs(&self, context: &mut Context) -> JsResult<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's time to find a better name for the original function. load_link_evaluate
sounds a bit spec-y and I think something like run
would also be fine. That would also make the name of this function a lot shorter; run_blocking
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eval_blocking
? Either way I can make the change in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though about something. I think people would also want to await other promises, so maybe it should be better to add an await_
method to JsPromise
? That sidesteps the need for a new method for the module, and you would just call
module.load_link_resolve(context).await_(context)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect to me!
#[derive(Debug, Clone, Trace, Finalize)] | ||
pub struct TypedJsFunction<A: TryIntoJsArguments, R: TryFromJs> { | ||
inner: JsFunction, | ||
_args: PhantomData<A>, | ||
_ret: PhantomData<R>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving this new API! It should help for strictness in many ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! :)
This allows to create a moderately simple example (see
tests/gcd.rs
) that can be used as a tutorial.There are some typing issues, notably the
name
argument inget_typed_fn
. Let's discuss.