Boot2Rust
Boot2Rust copied to clipboard
A few more comments?
Although Rust is pretty readable to a newcomer, some of the code is quite obscure, particularly in uefi.mod. For example:
((*(*self).output).OutputString)(self.output, str);
A few comments to explain what those do would help.
Is that necessary? If one can do self.output
somewhere, (*self).output
shouldn't be required, and Console
could be rewritten to use &'static
instead of raw pointers, but that wouldn't work because OutputString
takes a raw pointer.
Hmm... SimpleTextOutput
could be implemented by *EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
, making the code a little cleaner, but now I'm just nitpicking.
I thought about using &'static
instead of *
for the EFI stuff, but I'm not sure I have a good reason to prefer one way or the other. The code will probably be cleaner with &'static
, but it might be unsafer... It probably doesn't really matter, if you can't trust the UEFI code to do what it says then you probably have no hope of doing anything safely.
As far as comments, a lot of the stuff like the ((*(*self).output).OutputString)(self.output, str)
is meant to be hidden in the library, so I'm not as worried about this being quite so ugly (although breaking it into multiple lines with variables holding the intermediate results might help). At the very least, we should add doc comments though.