@@ -68,9 +68,9 @@ pub fn uefi_revision() -> Revision {
68
68
/// }
69
69
/// });
70
70
/// ```
71
- pub fn with_config_table < F , R > ( f : F ) -> R
71
+ pub fn with_config_table < F , R > ( mut f : F ) -> R
72
72
where
73
- F : Fn ( & [ ConfigTableEntry ] ) -> R ,
73
+ F : FnMut ( & [ ConfigTableEntry ] ) -> R ,
74
74
{
75
75
let st = table:: system_table_raw_panicking ( ) ;
76
76
// SAFETY: valid per requirements of `set_system_table`.
83
83
} else {
84
84
unsafe { slice:: from_raw_parts ( ptr, len) }
85
85
} ;
86
+
86
87
f ( slice)
87
88
}
88
89
92
93
///
93
94
/// This function will panic if called after exiting boot services, or if stdin
94
95
/// is not available.
95
- pub fn with_stdin < F , R > ( f : F ) -> R
96
+ pub fn with_stdin < F , R > ( mut f : F ) -> R
96
97
where
97
- F : Fn ( & mut Input ) -> R ,
98
+ F : FnMut ( & mut Input ) -> R ,
98
99
{
99
100
let st = table:: system_table_raw_panicking ( ) ;
100
101
// SAFETY: valid per requirements of `set_system_table`.
@@ -118,9 +119,9 @@ where
118
119
///
119
120
/// This function will panic if called after exiting boot services, or if stdout
120
121
/// is not available.
121
- pub fn with_stdout < F , R > ( f : F ) -> R
122
+ pub fn with_stdout < F , R > ( mut f : F ) -> R
122
123
where
123
- F : Fn ( & mut Output ) -> R ,
124
+ F : FnMut ( & mut Output ) -> R ,
124
125
{
125
126
let st = table:: system_table_raw_panicking ( ) ;
126
127
// SAFETY: valid per requirements of `set_system_table`.
@@ -144,9 +145,9 @@ where
144
145
///
145
146
/// This function will panic if called after exiting boot services, or if stderr
146
147
/// is not available.
147
- pub fn with_stderr < F , R > ( f : F ) -> R
148
+ pub fn with_stderr < F , R > ( mut f : F ) -> R
148
149
where
149
- F : Fn ( & mut Output ) -> R ,
150
+ F : FnMut ( & mut Output ) -> R ,
150
151
{
151
152
let st = table:: system_table_raw_panicking ( ) ;
152
153
// SAFETY: valid per requirements of `set_system_table`.
@@ -163,3 +164,28 @@ where
163
164
164
165
f ( stderr)
165
166
}
167
+
168
+ #[ cfg( test) ]
169
+ mod tests {
170
+ use super :: * ;
171
+
172
+ #[ allow( dead_code) ]
173
+ #[ allow( clippy:: assertions_on_constants) ]
174
+ fn with_config_table_compile_test ( ) {
175
+ assert ! ( false , "compile test only" ) ;
176
+
177
+ let mut acpi2_address = None ;
178
+
179
+ with_config_table ( |slice| {
180
+ for i in slice {
181
+ match i. guid {
182
+ ConfigTableEntry :: ACPI2_GUID => {
183
+ acpi2_address = Some ( i. address ) ;
184
+ break ;
185
+ }
186
+ _ => { }
187
+ }
188
+ }
189
+ } ) ;
190
+ }
191
+ }
0 commit comments