diff --git a/gdnative-core/src/nativescript/user_data.rs b/gdnative-core/src/nativescript/user_data.rs index 83f0eb7d8..2fd9634e6 100644 --- a/gdnative-core/src/nativescript/user_data.rs +++ b/gdnative-core/src/nativescript/user_data.rs @@ -440,6 +440,21 @@ impl Clone for RwLockData { #[derive(Debug)] pub struct ArcData(Arc); +impl ArcData { + /// Returns the internal `Arc`. Useful for API's that require an `Arc` + /// directly, or for coercing it into a trait object. + /// + /// Note that this removes + /// the restriction of only being able to access the `NativeClass` instance + /// temporarily through the `Map` trait; however, it should be exactly as safe + /// as permanently storing an owned `ArcData` and then calling `.map()` on + /// it later. + #[inline] + pub fn into_inner(self) -> Arc { + self.0 + } +} + unsafe impl UserData for ArcData where T: NativeClass + Send + Sync,