-
Notifications
You must be signed in to change notification settings - Fork 149
Description
I'd like to suggest integrating my os_units crate into the x86_64 crate.
Descriptions
The os_units crate provides two types: Bytes and NumOfPages. These types are interactive because of two methods: Bytes::as_num_of_pages and NumOfPages::as_bytes. Note that Bytes::as_num_of_pages returns the number of pages that is more than the bytes the instance of Bytes contains.
Advantages
Some methods will have more explicit return types. For example, Page implements Sub<Self>. However, the return type is u64, and it doesn't provide the information whether the number represents the bytes of pages or the number of pages (at first, I thought it was former). The users can read the docs (by the way, there is no information of its return type except the source code), but returning NumOfPages will prevent bugs because of the mismatch of types.
Drawbacks
The users will have to call as_usize (or as_u64 to match with the address types) each time, increasing the size of the code.
Notes
These two types use usize, not u64. However, changing the type to u64 will be better because this crate mainly uses it.