diff options
| author | KyleMiles <krm504@nyu.edu> | 2023-01-05 17:42:09 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2023-01-06 16:29:58 -0500 |
| commit | 676f6f8d8f26ad12de74638315792db0aa25df70 (patch) | |
| tree | 520b839dd48fb838493abe5c7cc23fc9c0683816 /rust/src | |
| parent | a154e45cce79b0c2264c1e1cd37a3d1bf5bc6154 (diff) | |
Rust API: Clean up APIs by removing artificial mut constriants
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/debuginfo.rs | 4 | ||||
| -rw-r--r-- | rust/src/types.rs | 22 |
2 files changed, 13 insertions, 13 deletions
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<S: BnStrCompatible>(&mut self, name: S, new_type: &Type) -> bool { + pub fn add_type<S: BnStrCompatible>(&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<S: BnStrCompatible>(&mut self, new_func: DebugFunctionInfo<S>) -> bool { + pub fn add_function<S: BnStrCompatible>(&self, new_func: DebugFunctionInfo<S>) -> 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<T: Into<Conf<bool>>>(&mut self, value: T) -> &mut Self { + pub fn set_const<T: Into<Conf<bool>>>(&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<T: Into<Conf<bool>>>(&mut self, value: T) -> &mut Self { + pub fn set_volatile<T: Into<Conf<bool>>>(&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<S: BnStrCompatible>(&mut self, name: S) -> &mut Self { + pub fn append<S: BnStrCompatible>(&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<S: BnStrCompatible>(&mut self, name: S, value: u64) -> &mut Self { + pub fn insert<S: BnStrCompatible>(&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<Conf<&'b Type>>>( - &'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 } |
