Skip to content

Commit 6dbcdee

Browse files
committed
Construct a SectionBuilder from a Section in Rust API
1 parent 261d217 commit 6dbcdee

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

rust/src/section.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,26 @@ impl SectionBuilder {
334334
}
335335
}
336336
}
337+
338+
impl<T: AsRef<Section>> From<T> for SectionBuilder {
339+
fn from(value: T) -> Self {
340+
let value = value.as_ref();
341+
let name = value.name().to_string_lossy().to_string();
342+
let ty = value.section_type().to_string();
343+
let linked_section = value.linked_section().to_string_lossy().to_string();
344+
let info_section = value.info_section().to_string_lossy().to_string();
345+
346+
Self {
347+
is_auto: value.auto_defined(),
348+
name,
349+
range: value.address_range(),
350+
semantics: value.semantics(),
351+
ty,
352+
align: value.align(),
353+
entry_size: value.entry_size() as u64,
354+
linked_section,
355+
info_section,
356+
info_data: value.info_data(),
357+
}
358+
}
359+
}

0 commit comments

Comments
 (0)