diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index 66d29eb64..9e95b554d 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -268,15 +268,12 @@ impl Drop for InstructionTextToken { impl CoreArrayProvider for InstructionTextToken { type Raw = BNInstructionTextToken; type Context = (); + type Wrapped<'a> = Self; } -unsafe impl CoreOwnedArrayProvider for InstructionTextToken { +unsafe impl CoreArrayProviderInner for InstructionTextToken { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeInstructionText(raw, count) } -} -unsafe impl CoreArrayWrapper for InstructionTextToken { - type Wrapped<'a> = Self; - unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Self(*raw) } @@ -285,15 +282,12 @@ unsafe impl CoreArrayWrapper for InstructionTextToken { impl CoreArrayProvider for Array { type Raw = BNInstructionTextLine; type Context = (); + type Wrapped<'a> = Self; } -unsafe impl CoreOwnedArrayProvider for Array { +unsafe impl CoreArrayProviderInner for Array { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeInstructionTextLines(raw, count) } -} -unsafe impl CoreArrayWrapper for Array { - type Wrapped<'a> = Self; - unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Self::new(raw.tokens, raw.count, ()) } diff --git a/rust/src/function.rs b/rust/src/function.rs index 1875f1dc2..1a6452211 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -674,9 +674,7 @@ impl Function { ) -> DataBuffer { let size = size.unwrap_or(0); let state_raw = state.into_raw_value(); - return DataBuffer::from_raw(unsafe { - BNGetConstantData(self.handle, state_raw, value, size) - }); + DataBuffer::from_raw(unsafe { BNGetConstantData(self.handle, state_raw, value, size) }) } pub fn constants_referenced_by( diff --git a/rust/src/mlil/function.rs b/rust/src/mlil/function.rs index 56d958e50..4b0ad7bff 100644 --- a/rust/src/mlil/function.rs +++ b/rust/src/mlil/function.rs @@ -5,9 +5,7 @@ use binaryninjacore_sys::*; use crate::architecture::CoreArchitecture; use crate::basicblock::BasicBlock; use crate::function::{Function, Location}; -use crate::rc::{ - Array, CoreArrayProvider, CoreArrayWrapper, CoreOwnedArrayProvider, Ref, RefCountable, -}; +use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Ref, RefCountable}; use crate::string::BnStrCompatible; use crate::types::{Conf, PossibleValueSet, Type, UserVariableValues, Variable}; @@ -476,17 +474,12 @@ impl ILReferenceSource { impl CoreArrayProvider for ILReferenceSource { type Raw = BNILReferenceSource; type Context = Ref; + type Wrapped<'a> = Self; } - -unsafe impl CoreOwnedArrayProvider for ILReferenceSource { +unsafe impl CoreArrayProviderInner for ILReferenceSource { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeILReferences(raw, count) } -} - -unsafe impl CoreArrayWrapper for ILReferenceSource { - type Wrapped<'a> = Self; - unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Self::from_raw(*raw, context.to_owned()) } @@ -512,17 +505,13 @@ impl VariableReferenceSource { impl CoreArrayProvider for VariableReferenceSource { type Raw = BNVariableReferenceSource; type Context = Ref; + type Wrapped<'a> = Self; } -unsafe impl CoreOwnedArrayProvider for VariableReferenceSource { +unsafe impl CoreArrayProviderInner for VariableReferenceSource { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeVariableReferenceSourceList(raw, count) } -} - -unsafe impl CoreArrayWrapper for VariableReferenceSource { - type Wrapped<'a> = Self; - unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Self { var: Variable::from_raw(raw.var), diff --git a/rust/src/tags.rs b/rust/src/tags.rs index 875ff8dd5..0142ab0a9 100644 --- a/rust/src/tags.rs +++ b/rust/src/tags.rs @@ -80,16 +80,13 @@ impl ToOwned for Tag { impl CoreArrayProvider for Tag { type Raw = *mut BNTag; type Context = (); + type Wrapped<'a> = Guard<'a, Self>; } -unsafe impl CoreOwnedArrayProvider for Tag { +unsafe impl CoreArrayProviderInner for Tag { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeTagList(raw, count) } -} - -unsafe impl CoreArrayWrapper for Tag { - type Wrapped<'a> = Guard<'a, Self>; unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, context: &'a Self::Context) -> Self::Wrapped<'a> { Guard::new(Self { handle: *raw }, &context) } diff --git a/rust/src/types.rs b/rust/src/types.rs index c719d7e8d..44bc71f98 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1804,7 +1804,7 @@ impl StructureBuilder { &self, members: impl IntoIterator, ) -> &Self { - for (t, name) in members.into_iter() { + for (t, name) in members { self.append(t, name, MemberAccess::NoAccess, MemberScope::NoScope); } self @@ -3204,7 +3204,7 @@ impl UserVariableValues { result } pub fn all(&self) -> impl Iterator { - unsafe { &*self.vars }.into_iter().map(|var_val| { + unsafe { &*self.vars }.iter().map(|var_val| { let var = unsafe { Variable::from_raw(var_val.var) }; let def_site = ArchAndAddr { arch: unsafe { CoreArchitecture::from_raw(var_val.defSite.arch) }, @@ -3263,16 +3263,13 @@ impl ConstantReference { impl CoreArrayProvider for ConstantReference { type Raw = BNConstantReference; type Context = (); + type Wrapped<'a> = Self; } -unsafe impl CoreOwnedArrayProvider for ConstantReference { +unsafe impl CoreArrayProviderInner for ConstantReference { unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { BNFreeConstantReferenceList(raw) } -} - -unsafe impl CoreArrayWrapper for ConstantReference { - type Wrapped<'a> = Self; unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Self::from_raw(*raw) } @@ -3313,16 +3310,13 @@ impl IndirectBranchInfo { impl CoreArrayProvider for IndirectBranchInfo { type Raw = BNIndirectBranchInfo; type Context = (); + type Wrapped<'a> = Self; } -unsafe impl CoreOwnedArrayProvider for IndirectBranchInfo { +unsafe impl CoreArrayProviderInner for IndirectBranchInfo { unsafe fn free(raw: *mut Self::Raw, _count: usize, _context: &Self::Context) { BNFreeIndirectBranchList(raw) } -} - -unsafe impl CoreArrayWrapper for IndirectBranchInfo { - type Wrapped<'a> = Self; unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { Self::from_raw(*raw) } @@ -3452,7 +3446,7 @@ impl HighlightColor { Self::StandardHighlightColor { color, alpha } => BNHighlightColor { style: BNHighlightColorStyle::StandardHighlightColor, color: color.into_raw(), - alpha: alpha, + alpha, ..zeroed }, Self::MixedHighlightColor { @@ -3463,15 +3457,15 @@ impl HighlightColor { } => BNHighlightColor { color: color.into_raw(), mixColor: mix_color.into_raw(), - mix: mix, - alpha: alpha, + mix, + alpha, ..zeroed }, Self::CustomHighlightColor { r, g, b, alpha } => BNHighlightColor { - r: r, - g: g, - b: b, - alpha: alpha, + r, + g, + b, + alpha, ..zeroed }, }