From 676f6f8d8f26ad12de74638315792db0aa25df70 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Thu, 5 Jan 2023 17:42:09 -0500 Subject: Rust API: Clean up APIs by removing artificial mut constriants --- rust/src/debuginfo.rs | 4 ++-- rust/src/types.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'rust/src') diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs index 32b478fb..37335255 100644 --- a/rust/src/debuginfo.rs +++ b/rust/src/debuginfo.rs @@ -717,7 +717,7 @@ impl DebugInfo { } /// Adds a type scoped under the current parser's name to the debug info - pub fn add_type(&mut self, name: S, new_type: &Type) -> bool { + pub fn add_type(&self, name: S, new_type: &Type) -> bool { let name = name.into_bytes_with_nul(); unsafe { BNAddDebugType( @@ -729,7 +729,7 @@ impl DebugInfo { } /// Adds a function scoped under the current parser's name to the debug info - pub fn add_function(&mut self, new_func: DebugFunctionInfo) -> bool { + pub fn add_function(&self, new_func: DebugFunctionInfo) -> bool { let short_name_bytes = new_func.short_name.map(|name| name.into_bytes_with_nul()); let short_name = short_name_bytes .as_ref() diff --git a/rust/src/types.rs b/rust/src/types.rs index a8f023ad..d9b28b4c 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -310,13 +310,13 @@ impl TypeBuilder { // Settable properties - pub fn set_const>>(&mut self, value: T) -> &mut Self { + pub fn set_const>>(&self, value: T) -> &Self { let mut bool_with_confidence = value.into().into(); unsafe { BNTypeBuilderSetConst(self.handle, &mut bool_with_confidence) }; self } - pub fn set_volatile>>(&mut self, value: T) -> &mut Self { + pub fn set_volatile>>(&self, value: T) -> &Self { let mut bool_with_confidence = value.into().into(); unsafe { BNTypeBuilderSetVolatile(self.handle, &mut bool_with_confidence) }; self @@ -1401,7 +1401,7 @@ impl EnumerationBuilder { Enumeration::new(self) } - pub fn append(&mut self, name: S) -> &mut Self { + pub fn append(&self, name: S) -> &Self { let name = name.into_bytes_with_nul(); unsafe { BNAddEnumerationBuilderMember(self.handle, name.as_ref().as_ptr() as _); @@ -1409,7 +1409,7 @@ impl EnumerationBuilder { self } - pub fn insert(&mut self, name: S, value: u64) -> &mut Self { + pub fn insert(&self, name: S, value: u64) -> &Self { let name = name.into_bytes_with_nul(); unsafe { BNAddEnumerationBuilderMemberWithValue(self.handle, name.as_ref().as_ptr() as _, value); @@ -1430,7 +1430,7 @@ impl EnumerationBuilder { self } - pub fn remove(&mut self, id: usize) -> &mut Self { + pub fn remove(&self, id: usize) -> &Self { unsafe { BNRemoveEnumerationBuilderMember(self.handle, id); } @@ -1598,7 +1598,7 @@ impl StructureBuilder { // Chainable builders/setters - pub fn set_width(&mut self, width: u64) -> &mut Self { + pub fn set_width(&self, width: u64) -> &Self { unsafe { BNSetStructureBuilderWidth(self.handle, width); } @@ -1606,7 +1606,7 @@ impl StructureBuilder { self } - pub fn set_alignment(&mut self, alignment: usize) -> &mut Self { + pub fn set_alignment(&self, alignment: usize) -> &Self { unsafe { BNSetStructureBuilderAlignment(self.handle, alignment); } @@ -1614,7 +1614,7 @@ impl StructureBuilder { self } - pub fn set_packed(&mut self, packed: bool) -> &mut Self { + pub fn set_packed(&self, packed: bool) -> &Self { unsafe { BNSetStructureBuilderPacked(self.handle, packed); } @@ -1623,12 +1623,12 @@ impl StructureBuilder { } pub fn append<'a, 'b, S: BnStrCompatible, T: Into>>( - &'a mut self, + &'a self, t: T, name: S, access: MemberAccess, scope: MemberScope, - ) -> &'a mut Self { + ) -> &'a Self { let name = name.into_bytes_with_nul(); unsafe { BNAddStructureBuilderMember( @@ -1685,7 +1685,7 @@ impl StructureBuilder { self } - pub fn set_structure_type(&mut self, t: StructureType) -> &Self { + pub fn set_structure_type(&self, t: StructureType) -> &Self { unsafe { BNSetStructureBuilderType(self.handle, t) }; self } -- cgit v1.3.1