-
Notifications
You must be signed in to change notification settings - Fork 124
Closed
Labels
blocking-next-releaseThis issue should be resolved before we release on crates.ioThis issue should be resolved before we release on crates.iocompatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking
Description
Summary
Remove our dependency on the byteorder
crate and remove the byteorder
feature, making the byteorder
module available unconditinoally.
Progress
In progress in #583.
- Update #583 to have
const fn
s no longer beconst
so that it works with our MSRV - Support functions which are conditionally
const
depending on Rust version (as prototyped in #574) - Make byteorder functions conditionally
const
Description
Some potential users have expressed concerns over our dependency on the byteorder crate. I have not seen any uses of the types in our byteorder
module which mix those types with other uses of the byteorder crate, which implies that we could just define our own ByteOrder
trait rather than using the one from the byteorder crate and this wouldn't cause problems for users.
While we're at it, we could use a technique like the following to allow the methods on our types to be const fn
s:
use core::marker::PhantomData;
pub trait ByteOrder {
#[doc(hidden)]
const ORDER: Order;
}
#[doc(hidden)]
pub enum Order {
BigEndian,
LittleEndian,
}
#[repr(transparent)]
pub struct U64<O>([u8; core::mem::size_of::<u64>()], PhantomData<O>);
impl<O: ByteOrder> U64<O> {
pub const fn new(u: u64) -> U64<O> {
let bytes = match O::ORDER {
Order::BigEndian => u.to_be_bytes(),
Order::LittleEndian => u.to_le_bytes(),
};
U64(bytes, PhantomData)
}
}
Metadata
Metadata
Assignees
Labels
blocking-next-releaseThis issue should be resolved before we release on crates.ioThis issue should be resolved before we release on crates.iocompatibility-breakingChanges that are (likely to be) breakingChanges that are (likely to be) breaking