Skip to content
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

Implement JsLifetime for () #395

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

Sytten
Copy link
Contributor

@Sytten Sytten commented Nov 24, 2024

We need that for https://github.com/rquickjs/rquickjs-moduledef-ext to allow users to not have options

use rquickjs_moduledef_ext::{ModuleLoader, ModuleDefExt, ModuleImpl};

struct MyModule;

impl ModuleDefExt for MyModule {
     type Implementation = ModuleImpl<()>;

     fn implementation() -> &'static Self::Implementation {
         &ModuleImpl {
             declare: |decl| {
                 decl.declare("hello")?;
                 Ok(())
             },
             evaluate: |ctx, exports, options| {
                 exports.export("hello", "world".to_string())?;
                 Ok(())
             },
             name: "my-module",
         }
     }

     fn options(self) -> () {}
 }

 let (loader, resolver, initializer) = ModuleLoader::builder()
     .with_module(MyModule)
     .build();

Copy link
Owner

@DelSkayn DelSkayn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@DelSkayn DelSkayn merged commit 6d8f612 into DelSkayn:master Nov 25, 2024
29 checks passed
@Sytten Sytten deleted the ef-lifetime-empty branch November 25, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants