@@ -68,9 +68,9 @@ pub fn uefi_revision() -> Revision {
6868/// }
6969/// });
7070/// ```
71- pub fn with_config_table < F , R > ( f : F ) -> R
71+ pub fn with_config_table < F , R > ( mut f : F ) -> R
7272where
73- F : Fn ( & [ ConfigTableEntry ] ) -> R ,
73+ F : FnMut ( & [ ConfigTableEntry ] ) -> R ,
7474{
7575 let st = table:: system_table_raw_panicking ( ) ;
7676 // SAFETY: valid per requirements of `set_system_table`.
8383 } else {
8484 unsafe { slice:: from_raw_parts ( ptr, len) }
8585 } ;
86+
8687 f ( slice)
8788}
8889
9293///
9394/// This function will panic if called after exiting boot services, or if stdin
9495/// is not available.
95- pub fn with_stdin < F , R > ( f : F ) -> R
96+ pub fn with_stdin < F , R > ( mut f : F ) -> R
9697where
97- F : Fn ( & mut Input ) -> R ,
98+ F : FnMut ( & mut Input ) -> R ,
9899{
99100 let st = table:: system_table_raw_panicking ( ) ;
100101 // SAFETY: valid per requirements of `set_system_table`.
@@ -118,9 +119,9 @@ where
118119///
119120/// This function will panic if called after exiting boot services, or if stdout
120121/// is not available.
121- pub fn with_stdout < F , R > ( f : F ) -> R
122+ pub fn with_stdout < F , R > ( mut f : F ) -> R
122123where
123- F : Fn ( & mut Output ) -> R ,
124+ F : FnMut ( & mut Output ) -> R ,
124125{
125126 let st = table:: system_table_raw_panicking ( ) ;
126127 // SAFETY: valid per requirements of `set_system_table`.
@@ -144,9 +145,9 @@ where
144145///
145146/// This function will panic if called after exiting boot services, or if stderr
146147/// is not available.
147- pub fn with_stderr < F , R > ( f : F ) -> R
148+ pub fn with_stderr < F , R > ( mut f : F ) -> R
148149where
149- F : Fn ( & mut Output ) -> R ,
150+ F : FnMut ( & mut Output ) -> R ,
150151{
151152 let st = table:: system_table_raw_panicking ( ) ;
152153 // SAFETY: valid per requirements of `set_system_table`.
@@ -163,3 +164,28 @@ where
163164
164165 f ( stderr)
165166}
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