You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use BitLength in constant expressions when const_fn is stable #346
I did some work on this on this branch. I created a new function as_usize_bytes, but on #350 you mention using as_bytes_rounded_up which already exists, well as_usize_bytes_rounded_up does. If you're ok with the current code I'll look for the bits<->bytes conversions.
I don't have a strong preference here. Generally I prefer the code to avoid panic! so as_usize_bytes_rounded_up variant seems better with that in mind, because it is clear it will never panic and it is clear that it rounds. Maybe in the future we can get type-level programming in Rust such that we can restrict the input type to a multiple of 8. Alternatively, we could flip the definitions around so that the xxx_BITS variables are defined to have value 8 * xxx_BYTES. I don't have strong feelings either way there.
I pushed a commit using as_usize_bytes_rounded_up. It will break no_heap builds though.
IIRC, that function is marked #[cfg(feature = "use_heap")] only because it is only used by other functions that are marked that way. In other words, it is right to remove the #[cfg(feature = "use_heap")] if that is needed to make the no-heap builds work.
Activity
pietro commentedon Jan 15, 2019
I did some work on this on this branch. I created a new function
as_usize_bytes, but on #350 you mention usingas_bytes_rounded_upwhich already exists, wellas_usize_bytes_rounded_updoes. If you're ok with the current code I'll look for the bits<->bytes conversions.briansmith commentedon Jan 16, 2019
I don't have a strong preference here. Generally I prefer the code to avoid
panic!soas_usize_bytes_rounded_upvariant seems better with that in mind, because it is clear it will never panic and it is clear that it rounds. Maybe in the future we can get type-level programming in Rust such that we can restrict the input type to a multiple of 8. Alternatively, we could flip the definitions around so that thexxx_BITSvariables are defined to have value8 * xxx_BYTES. I don't have strong feelings either way there.pietro commentedon Jan 16, 2019
I pushed a commit using
as_usize_bytes_rounded_up. It will breakno_heapbuilds though.briansmith commentedon Jan 16, 2019
IIRC, that function is marked
#[cfg(feature = "use_heap")]only because it is only used by other functions that are marked that way. In other words, it is right to remove the#[cfg(feature = "use_heap")]if that is needed to make the no-heap builds work.