From 2f214f6c9935e8ce8df4732cde44a540a003258c Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 7 May 2025 19:22:21 -0400 Subject: [Rust] Reduce usage of `IntoCStr` in function signatures This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids. Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type. This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type. Special consideration must be made for symbols or other possible non utf-8 objects. This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8. --- rust/examples/high_level_il.rs | 2 +- rust/examples/medium_level_il.rs | 2 +- rust/examples/simple.rs | 2 +- rust/examples/type_printer.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/high_level_il.rs b/rust/examples/high_level_il.rs index d57509da..ddc8f08d 100644 --- a/rust/examples/high_level_il.rs +++ b/rust/examples/high_level_il.rs @@ -16,7 +16,7 @@ fn main() { println!("Function count: {}", bv.functions().len()); for func in &bv.functions() { - println!("{}:", func.symbol().full_name()); + println!("{:?}:", func.symbol().full_name()); let Ok(il) = func.high_level_il(true) else { continue; diff --git a/rust/examples/medium_level_il.rs b/rust/examples/medium_level_il.rs index 61c3a330..543a0856 100644 --- a/rust/examples/medium_level_il.rs +++ b/rust/examples/medium_level_il.rs @@ -16,7 +16,7 @@ fn main() { println!("Function count: {}", bv.functions().len()); for func in &bv.functions() { - println!("{}:", func.symbol().full_name()); + println!("{:?}:", func.symbol().full_name()); let Ok(il) = func.medium_level_il() else { continue; diff --git a/rust/examples/simple.rs b/rust/examples/simple.rs index f41cbf34..c6065d48 100644 --- a/rust/examples/simple.rs +++ b/rust/examples/simple.rs @@ -17,7 +17,7 @@ fn main() { println!("Function count: {}", bv.functions().len()); for func in &bv.functions() { - println!("{}:", func.symbol().full_name()); + println!("{:?}:", func.symbol().full_name()); for basic_block in &func.basic_blocks() { // TODO : This is intended to be refactored to be more nice to work with soon(TM) for addr in basic_block.as_ref() { diff --git a/rust/examples/type_printer.rs b/rust/examples/type_printer.rs index ea9c6a4d..846e1a09 100644 --- a/rust/examples/type_printer.rs +++ b/rust/examples/type_printer.rs @@ -35,5 +35,5 @@ fn main() { TokenEscapingType::NoTokenEscapingType, ); - println!("{}", printed_types.unwrap()); + println!("{:?}", printed_types.unwrap()); } -- cgit v1.3.1