Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add into_inner method to ArcData #700

Merged
merged 1 commit into from Feb 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions gdnative-core/src/nativescript/user_data.rs
Expand Up @@ -440,6 +440,21 @@ impl<T, OPT> Clone for RwLockData<T, OPT> {
#[derive(Debug)]
pub struct ArcData<T>(Arc<T>);

impl<T> ArcData<T> {
/// Returns the internal `Arc<T>`. 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<T> {
self.0
}
}

unsafe impl<T> UserData for ArcData<T>
where
T: NativeClass + Send + Sync,
Expand Down