Skip to content

Commit 1c2efdb

Browse files
committed
add global namespace alias
1 parent eaff3ec commit 1c2efdb

File tree

1 file changed

+8
-1
lines changed
  • crates/bevy_mod_scripting_core/src/bindings/function

1 file changed

+8
-1
lines changed

crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,20 @@ pub enum Namespace {
6363
OnType(TypeId),
6464
}
6565

66+
/// A type which implements [`IntoNamespace`] by always converting to the global namespace
67+
pub struct GlobalNamespace;
68+
6669
pub trait IntoNamespace {
6770
fn into_namespace() -> Namespace;
6871
}
6972

7073
impl<T: ?Sized + 'static> IntoNamespace for T {
7174
fn into_namespace() -> Namespace {
72-
Namespace::OnType(TypeId::of::<T>())
75+
if TypeId::of::<T>() == TypeId::of::<GlobalNamespace>() {
76+
Namespace::Global
77+
} else {
78+
Namespace::OnType(TypeId::of::<T>())
79+
}
7380
}
7481
}
7582

0 commit comments

Comments
 (0)