1
1
use std:: path:: Path ;
2
2
3
- use object:: { self , Object , Symbol , ObjectSymbol , SymbolIterator } ;
3
+ use object:: { self , Object , ObjectSymbol , Symbol , SymbolIterator } ;
4
4
5
5
/// Iterate through the symbols in an object file.
6
6
///
@@ -50,7 +50,11 @@ pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool
50
50
/// The symbol names must match exactly.
51
51
///
52
52
/// Panics if `path` is not a valid object file readable by the current user.
53
- pub fn missing_exact_symbols < ' a > ( path : impl AsRef < Path > , symbol_names : & [ & ' a str ] , pred : impl Fn ( & Symbol < ' _ , ' _ > ) -> bool ) -> Vec < & ' a str > {
53
+ pub fn missing_exact_symbols < ' a > (
54
+ path : impl AsRef < Path > ,
55
+ symbol_names : & [ & ' a str ] ,
56
+ pred : impl Fn ( & Symbol < ' _ , ' _ > ) -> bool ,
57
+ ) -> Vec < & ' a str > {
54
58
let mut found = vec ! [ false ; symbol_names. len( ) ] ;
55
59
with_symbol_iter ( path, |syms| {
56
60
for sym in syms. filter ( & pred) {
@@ -59,16 +63,19 @@ pub fn missing_exact_symbols<'a>(path: impl AsRef<Path>, symbol_names: &[&'a str
59
63
}
60
64
}
61
65
} ) ;
62
- return found. iter ( ) . enumerate ( )
63
- . filter_map ( |( i, found) | if !* found {
64
- Some ( symbol_names[ i] )
65
- } else {
66
- None
67
- } ) . collect ( ) ;
66
+ return found
67
+ . iter ( )
68
+ . enumerate ( )
69
+ . filter_map ( |( i, found) | if !* found { Some ( symbol_names[ i] ) } else { None } )
70
+ . collect ( ) ;
68
71
}
69
72
70
73
/// Assert that the symbol file contains all of the listed symbols and they all match the given predicate
71
- pub fn assert_contains_exact_symbols ( path : impl AsRef < Path > , symbol_names : & [ & str ] , pred : impl Fn ( & Symbol < ' _ , ' _ > ) -> bool ) {
74
+ pub fn assert_contains_exact_symbols (
75
+ path : impl AsRef < Path > ,
76
+ symbol_names : & [ & str ] ,
77
+ pred : impl Fn ( & Symbol < ' _ , ' _ > ) -> bool ,
78
+ ) {
72
79
let missing = missing_exact_symbols ( path. as_ref ( ) , symbol_names, pred) ;
73
80
if missing. len ( ) > 0 {
74
81
eprintln ! ( "{} does not contain symbol(s): " , path. as_ref( ) . display( ) ) ;
0 commit comments