Merge pull request #59 from emberian/bitvec-1
Upgrade to bitvec 1.0.0 (-rc1) in prep for 1.0 release in January
This commit is contained in:
commit
7186b413f8
2 changed files with 18 additions and 18 deletions
|
@ -13,7 +13,7 @@ tokio = ["tokio_1", "futures-core"]
|
|||
|
||||
[dependencies]
|
||||
libc = "0.2.89"
|
||||
bitvec = "0.22"
|
||||
bitvec = "1.0.0"
|
||||
nix = "0.23"
|
||||
|
||||
tokio_1 = { package = "tokio", version = "1.0", features = ["net"], optional = true }
|
||||
|
|
|
@ -10,20 +10,20 @@ use std::ops::{Deref, DerefMut};
|
|||
#[repr(transparent)]
|
||||
pub struct AttributeSetRef<T> {
|
||||
_indexer: std::marker::PhantomData<T>,
|
||||
bitslice: BitSlice<Lsb0, u8>,
|
||||
bitslice: BitSlice<u8>,
|
||||
}
|
||||
|
||||
impl<T: EvdevEnum> AttributeSetRef<T> {
|
||||
#[inline]
|
||||
fn new(bitslice: &BitSlice<Lsb0, u8>) -> &Self {
|
||||
// SAFETY: for<T> AttributeSet<T> is repr(transparent) over BitSlice<Lsb0, u8>
|
||||
unsafe { &*(bitslice as *const BitSlice<Lsb0, u8> as *const Self) }
|
||||
fn new(bitslice: &BitSlice<u8>) -> &Self {
|
||||
// SAFETY: for<T> AttributeSet<T> is repr(transparent) over BitSlice<u8>
|
||||
unsafe { &*(bitslice as *const BitSlice<u8> as *const Self) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn new_mut(bitslice: &mut BitSlice<Lsb0, u8>) -> &mut Self {
|
||||
// SAFETY: for<T> AttributeSet<T> is repr(transparent) over BitSlice<Lsb0, u8>
|
||||
unsafe { &mut *(bitslice as *mut BitSlice<Lsb0, u8> as *mut Self) }
|
||||
fn new_mut(bitslice: &mut BitSlice<u8>) -> &mut Self {
|
||||
// SAFETY: for<T> AttributeSet<T> is repr(transparent) over BitSlice<u8>
|
||||
unsafe { &mut *(bitslice as *mut BitSlice<u8> as *mut Self) }
|
||||
}
|
||||
|
||||
/// Returns `true` if this AttributeSet contains the passed T.
|
||||
|
@ -75,11 +75,11 @@ impl<T: ArrayedEvdevEnum> AttributeSet<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn as_bitslice(&self) -> &BitSlice<Lsb0, u8> {
|
||||
fn as_bitslice(&self) -> &BitSlice<u8> {
|
||||
T::array_as_slice(&self.container)
|
||||
}
|
||||
|
||||
fn as_mut_bitslice(&mut self) -> &mut BitSlice<Lsb0, u8> {
|
||||
fn as_mut_bitslice(&mut self) -> &mut BitSlice<u8> {
|
||||
T::array_as_slice_mut(&mut self.container)
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ pub trait EvdevEnum: Copy + 'static {
|
|||
|
||||
pub trait ArrayedEvdevEnum: EvdevEnum {
|
||||
type Array;
|
||||
fn array_as_slice(arr: &Self::Array) -> &BitSlice<Lsb0, u8>;
|
||||
fn array_as_slice_mut(arr: &mut Self::Array) -> &mut BitSlice<Lsb0, u8>;
|
||||
fn array_as_slice(arr: &Self::Array) -> &BitSlice<u8>;
|
||||
fn array_as_slice_mut(arr: &mut Self::Array) -> &mut BitSlice<u8>;
|
||||
fn array_as_buf(arr: &mut Self::Array) -> &mut [u8];
|
||||
fn zeroed_array() -> Self::Array;
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ macro_rules! evdev_enum {
|
|||
evdev_enum!(
|
||||
$t,
|
||||
Array: bitvec::BitArr!(for <$t>::COUNT, in u8),
|
||||
bitvec::array::BitArray::as_mut_raw_slice,
|
||||
bitvec::array::BitArray::zeroed(),
|
||||
bitvec::array::BitArray::as_raw_mut_slice,
|
||||
bitvec::array::BitArray::ZERO,
|
||||
$($(#[$attr])* $c = $val,)*
|
||||
);
|
||||
};
|
||||
|
@ -155,8 +155,8 @@ macro_rules! evdev_enum {
|
|||
evdev_enum!(
|
||||
$t,
|
||||
Array: Box<bitvec::BitArr!(for <$t>::COUNT, in u8)>,
|
||||
bitvec::array::BitArray::as_mut_raw_slice,
|
||||
Box::new(bitvec::array::BitArray::zeroed()),
|
||||
bitvec::array::BitArray::as_raw_mut_slice,
|
||||
Box::new(bitvec::array::BitArray::ZERO),
|
||||
$($(#[$attr])* $c = $val,)*
|
||||
);
|
||||
};
|
||||
|
@ -167,10 +167,10 @@ macro_rules! evdev_enum {
|
|||
) => {
|
||||
impl $crate::attribute_set::ArrayedEvdevEnum for $t {
|
||||
type Array = $Array;
|
||||
fn array_as_slice(arr: &Self::Array) -> &bitvec::slice::BitSlice<bitvec::order::Lsb0, u8> {
|
||||
fn array_as_slice(arr: &Self::Array) -> &bitvec::slice::BitSlice<u8> {
|
||||
arr
|
||||
}
|
||||
fn array_as_slice_mut(arr: &mut Self::Array) -> &mut bitvec::slice::BitSlice<bitvec::order::Lsb0, u8> {
|
||||
fn array_as_slice_mut(arr: &mut Self::Array) -> &mut bitvec::slice::BitSlice<u8> {
|
||||
arr
|
||||
}
|
||||
fn array_as_buf(arr: &mut Self::Array) -> &mut [u8] {
|
||||
|
|
Loading…
Reference in a new issue