From 36199b05038fb5318b7ff265f42d4ae63b9b67cc Mon Sep 17 00:00:00 2001 From: Waridley Date: Mon, 22 Feb 2021 14:16:56 -0600 Subject: [PATCH] Add into_inner method to ArcData --- gdnative-core/src/nativescript/user_data.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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,