Skip to content

Commit 36199b0

Browse files
committed
Add into_inner method to ArcData
1 parent 4bc7681 commit 36199b0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gdnative-core/src/nativescript/user_data.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,21 @@ impl<T, OPT> Clone for RwLockData<T, OPT> {
440440
#[derive(Debug)]
441441
pub struct ArcData<T>(Arc<T>);
442442

443+
impl<T> ArcData<T> {
444+
/// Returns the internal `Arc<T>`. Useful for API's that require an `Arc`
445+
/// directly, or for coercing it into a trait object.
446+
///
447+
/// Note that this removes
448+
/// the restriction of only being able to access the `NativeClass` instance
449+
/// temporarily through the `Map` trait; however, it should be exactly as safe
450+
/// as permanently storing an owned `ArcData` and then calling `.map()` on
451+
/// it later.
452+
#[inline]
453+
pub fn into_inner(self) -> Arc<T> {
454+
self.0
455+
}
456+
}
457+
443458
unsafe impl<T> UserData for ArcData<T>
444459
where
445460
T: NativeClass + Send + Sync,

0 commit comments

Comments
 (0)