Skip to content

Commit

Permalink
Rename trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Nov 30, 2024
1 parent aa2aa82 commit 8887501
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use rquickjs::{
/// }
/// }
/// ```
pub trait ModuleDefExt<O = ()> {
pub trait Extension<O = ()> {
type Implementation: ModuleImplementationType<O>;

fn globals(_globals: &Object<'_>, _options: &O) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! [`ModuleDef`](rquickjs::module::ModuleDef)
//! that would allow it to have options as input and set global.
pub use self::definition::{GlobalsOnly, ModuleDefExt, ModuleImpl};
pub use self::definition::{Extension, GlobalsOnly, ModuleImpl};
pub use self::loader::{GlobalInitializer, ModuleLoader, ModuleLoaderBuilder, ModuleResolver};

mod definition;
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[macro_export]
macro_rules! globals_only_module {
($name:ident, |$globals:ident| { $($t:tt)* }) => {
impl ModuleDefExt for $name {
impl Extension for $name {
type Implementation = GlobalsOnly;

fn globals(globals: &Object<'_>, _options: &()) -> Result<()> {
Expand Down
10 changes: 5 additions & 5 deletions src/wrapper/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use rquickjs::{
};

use super::{IntoModule, ModuleMeta};
use crate::{GlobalsOnly, ModuleDefExt};
use crate::{GlobalsOnly, Extension};

pub struct GlobalDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
T: Extension<O, Implementation = GlobalsOnly>,
for<'js> O: JsLifetime<'js>,
{
_marker: std::marker::PhantomData<T>,
Expand All @@ -17,14 +17,14 @@ where

impl<T, O> IntoModule<O, GlobalDefWrapper<T, O>> for T
where
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
T: Extension<O, Implementation = GlobalsOnly>,
for<'js> O: JsLifetime<'js>,
{
}

impl<T, O> ModuleMeta for GlobalDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
T: Extension<O, Implementation = GlobalsOnly>,
for<'js> O: JsLifetime<'js>,
{
fn name() -> &'static str {
Expand All @@ -40,7 +40,7 @@ where

impl<T, O> ModuleDef for GlobalDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
T: Extension<O, Implementation = GlobalsOnly>,
for<'js> O: JsLifetime<'js>,
{
//unused
Expand Down
4 changes: 2 additions & 2 deletions src/wrapper/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rquickjs::{module::ModuleDef, JsLifetime};

use crate::ModuleDefExt;
use crate::Extension;

mod globals;
mod module;
Expand All @@ -19,7 +19,7 @@ pub trait ModuleMeta {
/// Semantically convert a [`ModuleDefExt`] to a [`ModuleDef`] and [`ModuleMeta`]
pub trait IntoModule<O, R>
where
Self: ModuleDefExt<O>,
Self: Extension<O>,
R: ModuleDef + ModuleMeta,
for<'js> O: JsLifetime<'js>,
{
Expand Down
10 changes: 5 additions & 5 deletions src/wrapper/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use rquickjs::{
};

use super::{IntoModule, ModuleMeta};
use crate::{ModuleDefExt, ModuleImpl};
use crate::{Extension, ModuleImpl};

pub struct ModuleDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
T: Extension<O, Implementation = ModuleImpl<O>>,
for<'js> O: JsLifetime<'js>,
{
_marker: std::marker::PhantomData<T>,
Expand All @@ -17,14 +17,14 @@ where

impl<T, O> IntoModule<O, ModuleDefWrapper<T, O>> for T
where
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
T: Extension<O, Implementation = ModuleImpl<O>>,
for<'js> O: JsLifetime<'js> + 'static,
{
}

impl<T, O> ModuleMeta for ModuleDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
T: Extension<O, Implementation = ModuleImpl<O>>,
for<'c> O: JsLifetime<'c> + 'static,
{
fn name() -> &'static str {
Expand All @@ -38,7 +38,7 @@ where

impl<T, O> ModuleDef for ModuleDefWrapper<T, O>
where
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
T: Extension<O, Implementation = ModuleImpl<O>>,
for<'js> O: JsLifetime<'js> + 'static,
{
fn declare(decl: &Declarations) -> Result<()> {
Expand Down

0 comments on commit 8887501

Please sign in to comment.