Open asoderman opened 2 years ago
Perhaps we could approach this from another angle: The SliceIndex
trait is used in the standard library to allow indexing with multiple different types. This was already considered in https://github.com/rust-osdev/x86_64/pull/95#issuecomment-557496537 and later ruled out in https://github.com/rust-osdev/x86_64/pull/319 because SliceIndex
is based on usize
and not u8
.
Instead, perhaps we could implement our own trait InterruptDescriptorTableIndex
that would be implemented on u8
as well as all the range types and use that type for the bounds checks in the macro. The same trait could probably be used for InterruptDescriptorTable::slice
as well as InterruptDescriptorTable::index
.
Hello, please consider this small QOL change to the set_general_handler macro.
This would allow the index to be specified by a const or variable e.g.
instead of being forced to convert it to a range
I'm not sure if there's any way to make this change less repetitive by having
$idx
be either literal or ident. It might also be worth considering refactoring out the setting individual handler functionality (the$idx
variants) into its own macro and allow users to pass a$range:ident
to the current macro to avoid ambiguity.