From 87b1470b2de74640c856d8a90ba88ec672713d71 Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Wed, 1 May 2024 10:43:58 -0400 Subject: rust: account for changes to NameAndType bindings --- rust/src/types.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'rust/src/types.rs') diff --git a/rust/src/types.rs b/rust/src/types.rs index dae8a6cc..75c8fb36 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -2440,16 +2440,11 @@ unsafe impl CoreArrayWrapper for QualifiedNameTypeAndId { ////////////////////////// // NameAndType -#[repr(transparent)] pub struct NameAndType(pub(crate) BNNameAndType); impl NameAndType { - pub(crate) fn from_raw(raw: &BNNameAndType) -> Ref { - Self::new( - raw_to_string(raw.name).unwrap(), - unsafe { &Type::ref_from_raw(raw.type_) }, - raw.typeConfidence, - ) + pub(crate) unsafe fn from_raw(raw: &BNNameAndType) -> Self { + Self ( *raw ) } } @@ -2464,10 +2459,6 @@ impl NameAndType { } } - pub(crate) fn into_raw(self) -> BNNameAndType { - self.0 - } - pub fn name(&self) -> &str { let c_str = unsafe { CStr::from_ptr(self.0.name) }; c_str.to_str().unwrap() @@ -2495,7 +2486,7 @@ unsafe impl RefCountable for NameAndType { Self::new( CStr::from_ptr(handle.0.name), handle.t(), - handle.type_with_confidence().confidence, + handle.0.typeConfidence, ) } @@ -2519,10 +2510,10 @@ unsafe impl CoreOwnedArrayProvider for NameAndType { } unsafe impl CoreArrayWrapper for NameAndType { - type Wrapped<'a> = &'a NameAndType; + type Wrapped<'a> = Guard<'a, NameAndType>; unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { - mem::transmute(raw) + unsafe { Guard::new(NameAndType::from_raw(raw), raw) } } } -- cgit v1.3.1