1
- use std :: path :: Path ;
1
+ use object :: { self , Object , ObjectSymbol , SymbolIterator } ;
2
2
use std:: fs;
3
- use object :: { self , Object , SymbolIterator , ObjectSymbol } ;
3
+ use std :: path :: Path ;
4
4
5
5
/// iterate through the symbols in an object file.
6
6
///
7
7
/// uses a callback because SymbolIterator does not own its data
8
- pub fn with_symbol_iter < P , F , R > ( path : P , func : F ) -> R where
8
+ pub fn with_symbol_iter < P , F , R > ( path : P , func : F ) -> R
9
+ where
9
10
P : AsRef < Path > ,
10
11
//I: Iterator + 'a,
11
12
F : FnOnce ( & mut SymbolIterator < ' _ , ' _ > ) -> R ,
12
13
{
13
14
let raw_bytes = fs:: read ( path) . expect ( "unable to read file" ) ;
14
- let f = object:: File :: parse ( raw_bytes. as_slice ( ) )
15
- . expect ( "unable to parse file" ) ;
15
+ let f = object:: File :: parse ( raw_bytes. as_slice ( ) ) . expect ( "unable to parse file" ) ;
16
16
let mut iter = f. symbols ( ) ;
17
17
func ( & mut iter)
18
18
}
@@ -21,7 +21,10 @@ pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool
21
21
with_symbol_iter ( path, |syms| {
22
22
for sym in syms {
23
23
for substring in substrings {
24
- if sym. name_bytes ( ) . unwrap ( ) . windows ( substring. len ( ) )
24
+ if sym
25
+ . name_bytes ( )
26
+ . unwrap ( )
27
+ . windows ( substring. len ( ) )
25
28
. any ( |x| x == substring. as_bytes ( ) )
26
29
{
27
30
eprintln ! ( "{:?} contains {}" , sym, substring) ;
0 commit comments