summaryrefslogtreecommitdiff
path: root/rust/src/debuginfo.rs
diff options
context:
space:
mode:
authorMichael Krasnitski <michael.krasnitski@gmail.com>2023-01-06 14:13:55 -0500
committerKyleMiles <krm504@nyu.edu>2023-01-06 18:04:05 -0500
commitad7f5293db22e23d8d50077aa99f5d7a904092fc (patch)
tree294217bc06b0cdc3a86ebdb1132ad8cddd02d5ce /rust/src/debuginfo.rs
parentc97b7d878c048312257843ee585280cc07a906e7 (diff)
Rust API: Additional Cleanup
Diffstat (limited to 'rust/src/debuginfo.rs')
-rw-r--r--rust/src/debuginfo.rs61
1 files changed, 32 insertions, 29 deletions
diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs
index 37335255..3ec0691c 100644
--- a/rust/src/debuginfo.rs
+++ b/rust/src/debuginfo.rs
@@ -575,15 +575,16 @@ impl DebugInfo {
let names_and_types: &[*mut BNNameAndType] =
unsafe { slice::from_raw_parts(raw_names_and_types as *mut _, count) };
- let mut result = Vec::with_capacity(count);
- for name_and_type in names_and_types.iter().take(count) {
- unsafe {
- result.push((
- raw_to_string((**name_and_type).name).unwrap(),
- Type::ref_from_raw(BNNewTypeReference((**name_and_type).type_)),
- ))
- };
- }
+ let result = names_and_types
+ .iter()
+ .take(count)
+ .map(|&name_and_type| unsafe {
+ (
+ raw_to_string((*name_and_type).name).unwrap(),
+ Type::ref_from_raw(BNNewTypeReference((*name_and_type).type_)),
+ )
+ })
+ .collect();
unsafe { BNFreeNameAndTypeList(raw_names_and_types, count) };
result
@@ -604,16 +605,17 @@ impl DebugInfo {
let variables_and_names: &[*mut BNDataVariableAndName] =
unsafe { slice::from_raw_parts(raw_variables_and_names as *mut _, count) };
- let mut result = Vec::with_capacity(count);
- for variable_and_name in variables_and_names.iter().take(count) {
- unsafe {
- result.push((
- raw_to_string((**variable_and_name).name).unwrap(),
- (**variable_and_name).address,
- Type::ref_from_raw(BNNewTypeReference((**variable_and_name).type_)),
- ))
- };
- }
+ let result = variables_and_names
+ .iter()
+ .take(count)
+ .map(|&variable_and_name| unsafe {
+ (
+ raw_to_string((*variable_and_name).name).unwrap(),
+ (*variable_and_name).address,
+ Type::ref_from_raw(BNNewTypeReference((*variable_and_name).type_)),
+ )
+ })
+ .collect();
unsafe { BNFreeDataVariablesAndName(raw_variables_and_names, count) };
result
@@ -628,16 +630,17 @@ impl DebugInfo {
let variables_and_names: &[*mut BNDataVariableAndNameAndDebugParser] =
unsafe { slice::from_raw_parts(raw_variables_and_names as *mut _, count) };
- let mut result = Vec::with_capacity(count);
- for variable_and_name in variables_and_names.iter().take(count) {
- unsafe {
- result.push((
- raw_to_string((**variable_and_name).parser).unwrap(),
- raw_to_string((**variable_and_name).name).unwrap(),
- Type::ref_from_raw(BNNewTypeReference((**variable_and_name).type_)),
- ))
- };
- }
+ let result = variables_and_names
+ .iter()
+ .take(count)
+ .map(|&variable_and_name| unsafe {
+ (
+ raw_to_string((*variable_and_name).parser).unwrap(),
+ raw_to_string((*variable_and_name).name).unwrap(),
+ Type::ref_from_raw(BNNewTypeReference((*variable_and_name).type_)),
+ )
+ })
+ .collect();
unsafe { BNFreeDataVariableAndNameAndDebugParserList(raw_variables_and_names, count) };
result