blog_os
blog_os copied to clipboard
Small refactoring in "Hardware interrupts" chapter
There is a code https://os.phil-opp.com/hardware-interrupts/#handling-timer-interrupts
Any reason to make this:
impl InterruptIndex {
fn as_u8(self) -> u8 {
self as u8
}
fn as_usize(self) -> usize {
usize::from(self.as_u8())
}
}
and not this:
impl InterruptIndex {
fn as_usize(self) -> usize {
usize::from(self as u8)
}
}
or even not to create as_usize
at all, and just use as usize
cast directly?
Thanks for attention.
as_u8
is used in various places where we actually need u8
. as_usize
could still be rewritten to not use as_u8
though.
Then wouldn't it be better to use as u8
or as usize
everywhere and get rid off this impl's ?
I'd consider as u8
to be more noisy than .as_u8()
.