summaryrefslogtreecommitdiff
path: root/rust/src/platform.rs
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2021-06-08 17:23:28 -0400
committerKyleMiles <krm504@nyu.edu>2021-07-07 23:27:28 -0400
commit8785e9d1a931d7562053fd6045b660a6211fbc1d (patch)
tree4506696e861fcffa3e321bd32e00621a90a42693 /rust/src/platform.rs
parent013945b3efa885101db16990311093912775d1c6 (diff)
Rust API : Replace Platform::from_raw with Platform::ref_from_raw
Diffstat (limited to 'rust/src/platform.rs')
-rw-r--r--rust/src/platform.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/rust/src/platform.rs b/rust/src/platform.rs
index bc5cb9f1..b79b9611 100644
--- a/rust/src/platform.rs
+++ b/rust/src/platform.rs
@@ -64,10 +64,10 @@ macro_rules! cc_func {
}
impl Platform {
- pub(crate) unsafe fn from_raw(handle: *mut BNPlatform) -> Self {
+ pub(crate) unsafe fn ref_from_raw(handle: *mut BNPlatform) -> Ref<Self> {
debug_assert!(!handle.is_null());
- Self { handle }
+ Ref::new(Self { handle })
}
pub fn by_name<S: BnStrCompatible>(name: S) -> Option<Ref<Self>> {
@@ -360,6 +360,7 @@ unsafe impl<'a> CoreOwnedArrayWrapper<'a> for Platform {
type Wrapped = Guard<'a, Platform>;
unsafe fn wrap_raw(raw: &'a *mut BNPlatform, context: &'a ()) -> Guard<'a, Platform> {
- Guard::new(Platform::from_raw(*raw), context)
+ debug_assert!(!raw.is_null());
+ Guard::new(Platform { handle: *raw }, context)
}
}