From bf3501aecfda73acca7d338316f4eb2f0adee41e Mon Sep 17 00:00:00 2001 From: zach Date: Fri, 22 Mar 2024 07:38:45 -0700 Subject: [PATCH] use immutable runtime handle --- derive/src/lib.rs | 4 ++-- src/lib.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/derive/src/lib.rs b/derive/src/lib.rs index 4d9be6c..59aeacb 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -219,7 +219,7 @@ pub fn ocaml_func(attribute: TokenStream, item: TokenStream) -> TokenStream { let inner = if returns { quote! { #[inline(always)] - #constness #unsafety fn inner(#gc_name: &mut ocaml::Runtime, #(#rust_args),*) -> #rust_return_type { + #constness #unsafety fn inner(#gc_name: &ocaml::Runtime, #(#rust_args),*) -> #rust_return_type { #use_gc #body } @@ -227,7 +227,7 @@ pub fn ocaml_func(attribute: TokenStream, item: TokenStream) -> TokenStream { } else { quote! { #[inline(always)] - #constness #unsafety fn inner(#gc_name: &mut ocaml::Runtime, #(#rust_args),*) { + #constness #unsafety fn inner(#gc_name: &ocaml::Runtime, #(#rust_args),*) { #use_gc #body } diff --git a/src/lib.rs b/src/lib.rs index e7904de..7317948 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -223,8 +223,8 @@ impl Runtime { #[doc(hidden)] #[inline(always)] - pub unsafe fn recover_handle() -> &'static mut Self { - static mut RUNTIME: Runtime = Runtime { _private: () }; - &mut RUNTIME + pub unsafe fn recover_handle() -> &'static Self { + static RUNTIME: Runtime = Runtime { _private: () }; + &RUNTIME } }