From 7090d904513c3e80321bb6a8aba9c3b37d809bac Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sat, 6 Dec 2025 17:06:16 -0500 Subject: [Rust] Remove redundant `ArchAndAddr` type Use `Location` instead, `arch` can be a nullptr --- rust/src/function.rs | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) (limited to 'rust/src/function.rs') diff --git a/rust/src/function.rs b/rust/src/function.rs index 5e4cf08a..1ef0a377 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -71,20 +71,21 @@ impl Location { arch: Some(unsafe { CoreArchitecture::from_raw(arch) }), } } + + pub fn new(arch: Option, addr: u64) -> Self { + Self { arch, addr } + } } impl From for Location { fn from(addr: u64) -> Self { - Location { arch: None, addr } + Location::new(None, addr) } } impl From<(CoreArchitecture, u64)> for Location { fn from(loc: (CoreArchitecture, u64)) -> Self { - Location { - arch: Some(loc.0), - addr: loc.1, - } + Location::new(Some(loc.0), loc.1) } } @@ -2998,34 +2999,3 @@ unsafe impl CoreArrayProviderInner for Comment { } } } - -#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] -pub struct ArchAndAddr { - pub arch: CoreArchitecture, - pub addr: u64, -} - -impl ArchAndAddr { - pub fn new(arch: CoreArchitecture, addr: u64) -> Self { - Self { arch, addr } - } -} - -impl From for ArchAndAddr { - fn from(raw: BNArchitectureAndAddress) -> Self { - unsafe { - let arch = CoreArchitecture::from_raw(raw.arch); - let addr = raw.address; - ArchAndAddr { arch, addr } - } - } -} - -impl ArchAndAddr { - pub fn into_raw(self) -> BNArchitectureAndAddress { - BNArchitectureAndAddress { - arch: self.arch.handle, - address: self.addr, - } - } -} -- cgit v1.3.1