Skip to content

Commit

Permalink
Explicitly allow the static mut references where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Dec 17, 2024
1 parent 4a35f34 commit 3e3d817
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rustler/src/resource/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type NifResourcePtr = *const ErlNifResourceType;
static mut RESOURCE_TYPES: OnceLock<HashMap<TypeId, usize>> = OnceLock::new();

/// Register an Erlang resource type handle for a particular type given by its `TypeId`
#[allow(static_mut_refs)]
pub(crate) unsafe fn register_resource_type(type_id: TypeId, resource_type: NifResourcePtr) {
RESOURCE_TYPES.get_or_init(Default::default);
RESOURCE_TYPES
Expand Down Expand Up @@ -64,6 +65,7 @@ pub trait Resource: Sized + Send + Sync + 'static {
#[doc(hidden)]
pub(crate) trait ResourceExt: 'static {
/// Get the NIF resource type handle for this type if it had been registered before
#[allow(static_mut_refs)]
fn get_resource_type() -> Option<NifResourcePtr> {
let map = unsafe { RESOURCE_TYPES.get()? };
map.get(&TypeId::of::<Self>())
Expand Down
1 change: 1 addition & 0 deletions rustler/src/sys/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub unsafe fn internal_set_symbols(callbacks: DynNifCallbacks) {
DYN_NIF_CALLBACKS = callbacks;
}

#[allow(static_mut_refs)]
pub unsafe fn internal_write_symbols() {
let filler = nif_filler::new();
DYN_NIF_CALLBACKS.write_symbols(filler);
Expand Down

0 comments on commit 3e3d817

Please sign in to comment.