Skip to content

Question on how to access to stdin, stdout (and stderr) since 0.32 #1400

@YtvwlD

Description

@YtvwlD

Hi, I'm trying to display a menu. With older versions of uefi-rs, I'd have a function

pub fn choose<'a>(config: &'a Config, systab: &mut SystemTable<Boot>) -> &'a Entry

that accesses systab.stdin() and systab.stdout(). Since that is now deprecated, how would I change this?
The migration document doesn't mention stdin or stdout.

I've thought of this:

pub fn choose<'a>(config: &'a Config, stdin: &mut Input, stdout: &mut Output) -> &'a Entry

but I can't call it with:

let entry_to_boot = with_stdin(|stdin| with_stdout(
    |stdout| menu::choose(&config, stdin, stdout)
));

as this produces the following error:

error[E0596]: cannot borrow `*stdin` as mutable, as it is a captured variable in a `Fn` closure
   --> src/main.rs:117:40
    |
31  | fn efi_main(image: Handle, mut systab: SystemTable<Boot>) -> Status {
    |    --------                                                  ------ change this to return `FnMut` instead of `Fn`
...
117 |         |stdout| menu::choose(&config, stdin, stdout)
    |         -------- in this closure       ^^^^^ cannot borrow as mutable

Do I have to put the calls to with_stdin and with_stdout inside the function?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions