Skip to content

Commit 7dfe64e

Browse files
committed
Rename traits
1 parent aab0fc5 commit 7dfe64e

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

src/loader/builder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rquickjs::{
66
};
77

88
use super::{GlobalInitializer, GlobalLoadFn, ModuleLoadFn, ModuleLoader, ModuleResolver};
9-
use crate::wrapper::{AsModule, HasModule};
9+
use crate::wrapper::{IntoModule, ModuleMeta};
1010

1111
fn load_module_func<D: ModuleDef>(ctx: Ctx<'_>, name: Vec<u8>) -> Result<Module<'_>> {
1212
Module::declare_def::<D, _>(ctx, name)
@@ -53,8 +53,8 @@ impl ModuleLoaderBuilder {
5353
pub fn with_module<O, M, R>(mut self, module: M) -> Self
5454
where
5555
for<'js> O: JsLifetime<'js> + 'static,
56-
R: ModuleDef + HasModule,
57-
M: AsModule<O, R>,
56+
R: ModuleDef + ModuleMeta,
57+
M: IntoModule<O, R>,
5858
{
5959
self.process_module(module, None);
6060
self
@@ -64,8 +64,8 @@ impl ModuleLoaderBuilder {
6464
pub fn with_module_named<O, M, R>(mut self, module: M, name: &'static str) -> Self
6565
where
6666
for<'js> O: JsLifetime<'js> + 'static,
67-
R: ModuleDef + HasModule,
68-
M: AsModule<O, R>,
67+
R: ModuleDef + ModuleMeta,
68+
M: IntoModule<O, R>,
6969
{
7070
self.process_module(module, Some(name));
7171
self
@@ -74,26 +74,26 @@ impl ModuleLoaderBuilder {
7474
pub fn add_module<O, M, R>(&mut self, module: M) -> &mut Self
7575
where
7676
for<'js> O: JsLifetime<'js> + 'static,
77-
R: ModuleDef + HasModule,
78-
M: AsModule<O, R>,
77+
R: ModuleDef + ModuleMeta,
78+
M: IntoModule<O, R>,
7979
{
8080
self.process_module(module, None)
8181
}
8282

8383
pub fn add_module_named<O, M, R>(&mut self, module: M, name: &'static str) -> &mut Self
8484
where
8585
for<'js> O: JsLifetime<'js> + 'static,
86-
R: ModuleDef + HasModule,
87-
M: AsModule<O, R>,
86+
R: ModuleDef + ModuleMeta,
87+
M: IntoModule<O, R>,
8888
{
8989
self.process_module(module, Some(name))
9090
}
9191

9292
fn process_module<O, M, R>(&mut self, module: M, name: Option<&'static str>) -> &mut Self
9393
where
9494
for<'js> O: JsLifetime<'js> + 'static,
95-
R: ModuleDef + HasModule,
96-
M: AsModule<O, R>,
95+
R: ModuleDef + ModuleMeta,
96+
M: IntoModule<O, R>,
9797
{
9898
let o = module.options();
9999

src/wrapper/globals.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rquickjs::{
33
Ctx, JsLifetime, Result,
44
};
55

6-
use super::{AsModule, HasModule};
6+
use super::{IntoModule, ModuleMeta};
77
use crate::{GlobalsOnly, ModuleDefExt};
88

99
pub struct GlobalDefWrapper<T, O>
@@ -15,14 +15,14 @@ where
1515
_marker2: std::marker::PhantomData<O>,
1616
}
1717

18-
impl<T, O> AsModule<O, GlobalDefWrapper<T, O>> for T
18+
impl<T, O> IntoModule<O, GlobalDefWrapper<T, O>> for T
1919
where
2020
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
2121
for<'js> O: JsLifetime<'js>,
2222
{
2323
}
2424

25-
impl<T, O> HasModule for GlobalDefWrapper<T, O>
25+
impl<T, O> ModuleMeta for GlobalDefWrapper<T, O>
2626
where
2727
T: ModuleDefExt<O, Implementation = GlobalsOnly>,
2828
for<'js> O: JsLifetime<'js>,

src/wrapper/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ mod module;
1111
/// converted it from a [`ModuleDefExt`] to a [`ModuleDef`].
1212
///
1313
/// This is necessary for the loader to work.
14-
pub trait HasModule {
14+
pub trait ModuleMeta {
1515
fn name() -> &'static str;
1616
fn is_module() -> bool;
1717
}
1818

19-
/// Semantically convert a [`ModuleDefExt`] to a [`ModuleDef`] and [`HasModule`]
20-
pub trait AsModule<O, R>
19+
/// Semantically convert a [`ModuleDefExt`] to a [`ModuleDef`] and [`ModuleMeta`]
20+
pub trait IntoModule<O, R>
2121
where
2222
Self: ModuleDefExt<O>,
23-
R: ModuleDef + HasModule,
23+
R: ModuleDef + ModuleMeta,
2424
for<'js> O: JsLifetime<'js>,
2525
{
2626
}

src/wrapper/module.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rquickjs::{
33
Ctx, JsLifetime, Result,
44
};
55

6-
use super::{AsModule, HasModule};
6+
use super::{IntoModule, ModuleMeta};
77
use crate::{ModuleDefExt, ModuleImpl};
88

99
pub(crate) struct ModuleDefWrapper<T, O>
@@ -15,20 +15,14 @@ where
1515
_marker2: std::marker::PhantomData<O>,
1616
}
1717

18-
impl<T, O> AsModule<O, ModuleDefWrapper<T, O>> for T
18+
impl<T, O> IntoModule<O, ModuleDefWrapper<T, O>> for T
1919
where
2020
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
2121
for<'js> O: JsLifetime<'js> + 'static,
2222
{
23-
// fn as_module(&self) -> ModuleDefWrapper<T, O> {
24-
// ModuleDefWrapper {
25-
// _marker: std::marker::PhantomData::<T>,
26-
// _marker2: std::marker::PhantomData::<O>,
27-
// }
28-
// }
2923
}
3024

31-
impl<T, O> HasModule for ModuleDefWrapper<T, O>
25+
impl<T, O> ModuleMeta for ModuleDefWrapper<T, O>
3226
where
3327
T: ModuleDefExt<O, Implementation = ModuleImpl<O>>,
3428
for<'c> O: JsLifetime<'c> + 'static,

0 commit comments

Comments
 (0)