Skip to content

Commit a39e29a

Browse files
committed
[Rust] Impl Display for Symbol
1 parent bf012e1 commit a39e29a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

rust/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
println!("Function count: {}", bv.functions().len());
3535

3636
for func in &bv.functions() {
37-
println!("{}:", func.symbol().full_name());
37+
println!("{}: {}", func.start(), func.symbol());
3838
}
3939
}
4040
```

rust/examples/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
println!("Function count: {}", bv.functions().len());
1818

1919
for func in &bv.functions() {
20-
println!("{:?}:", func.symbol().full_name());
20+
println!("{}:", func.symbol());
2121
for basic_block in &func.basic_blocks() {
2222
// TODO : This is intended to be refactored to be more nice to work with soon(TM)
2323
for addr in basic_block.as_ref() {

rust/src/symbol.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! Interfaces for the various kinds of symbols in a binary.
1616
1717
use std::fmt;
18-
use std::fmt::Debug;
18+
use std::fmt::{Debug, Display, Formatter};
1919
use std::hash::{Hash, Hasher};
2020
use std::ptr;
2121

@@ -349,3 +349,9 @@ impl PartialEq for Symbol {
349349
self.handle == other.handle
350350
}
351351
}
352+
353+
impl Display for Symbol {
354+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
355+
f.write_str(&self.short_name().to_string_lossy())
356+
}
357+
}

0 commit comments

Comments
 (0)