diff options
Diffstat (limited to 'rust/src/section.rs')
| -rw-r--r-- | rust/src/section.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/rust/src/section.rs b/rust/src/section.rs index 49642b4d..971204ba 100644 --- a/rust/src/section.rs +++ b/rust/src/section.rs @@ -70,13 +70,12 @@ impl Section { Self { handle: raw } } - #[allow(clippy::new_ret_no_self)] /// You need to create a section builder, customize that section, then add it to a binary view: /// /// ``` /// bv.add_section(Section::new().align(4).entry_size(4)) /// ``` - pub fn new<S: BnStrCompatible>(name: S, range: Range<u64>) -> SectionBuilder<S> { + pub fn builder<S: BnStrCompatible>(name: S, range: Range<u64>) -> SectionBuilder<S> { SectionBuilder::new(name, range) } @@ -204,7 +203,7 @@ pub struct SectionBuilder<S: BnStrCompatible> { impl<S: BnStrCompatible> SectionBuilder<S> { pub fn new(name: S, range: Range<u64>) -> Self { - SectionBuilder { + Self { is_auto: false, name, range, @@ -268,19 +267,12 @@ impl<S: BnStrCompatible> SectionBuilder<S> { let len = self.range.end.wrapping_sub(start); unsafe { - use std::ffi::CStr; - - let nul_str = CStr::from_bytes_with_nul_unchecked(b"\x00").as_ptr(); + let nul_str = std::ffi::CStr::from_bytes_with_nul_unchecked(b"\x00").as_ptr(); let name_ptr = name.as_ref().as_ptr() as *mut _; - let ty_ptr = ty - .as_ref() - .map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); - let linked_section_ptr = linked_section - .as_ref() - .map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); - let info_section_ptr = info_section - .as_ref() - .map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); + let ty_ptr = ty.map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); + let linked_section_ptr = + linked_section.map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); + let info_section_ptr = info_section.map_or(nul_str, |s| s.as_ref().as_ptr() as *mut _); if self.is_auto { BNAddAutoSection( |
