Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition 3: Post 3: Proposal to change the contents of a certain code snippet #1316

Open
a-usr opened this issue Apr 22, 2024 · 0 comments
Open

Comments

@a-usr
Copy link

a-usr commented Apr 22, 2024

For the Last snippet in post 3 it is mentioned that it was "required jump through some hoops to satisfy the borrow checker". However, when using a if let statement to pattern match the FrameBuffer out of the option and then getting the info and buffer like so:

fn kernel_main(boot_info: &'static mut bootloader_api::BootInfo) -> ! {
    if let Some(frame) = boot_info.framebuffer.as_mut(){
        // it is important to get the info first, or else the borrow checker will complain
        let info = frame.info();
        let buffer = frame.buffer_mut();
        init_logger(buffer, info);
    }
    loop{}
}

the borrow checker doesnt complain whatsoever.
Would it be possible to update your code accordingly?

@a-usr a-usr changed the title Edition 3: Post 3: Proposal to change the contents of a code snippet Edition 3: Post 3: Proposal to change the contents of a certain code snippet Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant