-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
A simple module loader from a function #3932
Conversation
This will be the foundation for having a combinatoric module loader system.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3932 +/- ##
==========================================
+ Coverage 47.24% 51.97% +4.72%
==========================================
Files 476 472 -4
Lines 46892 45181 -1711
==========================================
+ Hits 22154 23481 +1327
+ Misses 24738 21700 -3038 ☔ View full report in Codecov by Sentry. |
#[derive(Copy, Clone)] | ||
pub struct FnModuleLoader<F>(F, &'static str) | ||
where | ||
F: Fn(&JsString) -> Option<Module>; |
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.
Was thinking that maybe this should return JsResult<Module>
. We could also have a separate loader for that (FallibleFnModuleLoader
or something), but it seems better to just have this be the fallible version already.
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.
I'm thinking here that this is the simplest way to declare a module loader, without even worry about the error type and message; either the module exists or it doesn't. Even if it doesn't parse, or any other kind of error, just say it cannot be found.
I could see a better Option<Source>
though, and show errors on parsing after the function returns the source of the module. WDYT?
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.
Just a minor nitpick, besides that I looks good to me! :)
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! Hopefully in the future we'll be able to remove the Clone
requirement on many of the bounds, it just requires some design work around ModuleLoader
.
* A simple module loader from a function This will be the foundation for having a combinatoric module loader system. * Add more utility module loader types * clippies * Remove convenience functions and allow AsRef<Path> for constructing fs * clippies * Move FnModuleLoader to return a result, and add a new simpler loader * Address comment
This will be the foundation for having a combinatoric module loader system.