mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-07-16 07:16:13 +00:00
kata-slot-allocator: update bitvec dep to v1.0
With the newer rustc we can switch to the stable version of bitvec; this includes some api changes. Change-Id: I9a7af5c2699f9bdebedc06ee68f5e3b7b71b9d75 GitOrigin-RevId: 44d44f930e8b35830d819949b6203c584fea2be3
This commit is contained in:
parent
02e1b40885
commit
c4c0e01765
@ -9,7 +9,6 @@ default = []
|
||||
TRACE_OPS = []
|
||||
|
||||
[dependencies]
|
||||
# TODO(sleffler): v1.0 requires rust edition2021
|
||||
bitvec = { version = "0.22", default-features = false, features = ["alloc"] }
|
||||
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||
log = "0.4"
|
||||
spin = "0.9"
|
||||
|
@ -12,7 +12,7 @@ use log::trace;
|
||||
use spin::Mutex;
|
||||
|
||||
struct Slots {
|
||||
bits: Option<BitBox<Lsb0, u8>>,
|
||||
bits: Option<BitBox<u8, Lsb0>>,
|
||||
used: usize,
|
||||
name: &'static str, // Component name
|
||||
// TODO(sleffler): maybe track last alloc for O(1) sequential allocations
|
||||
@ -20,7 +20,7 @@ struct Slots {
|
||||
impl Slots {
|
||||
fn new(name: &'static str, size: usize) -> Self {
|
||||
Slots {
|
||||
bits: Some(bitvec![Lsb0, u8; 0; size].into_boxed_bitslice()),
|
||||
bits: Some(bitvec![u8, Lsb0; 0; size].into_boxed_bitslice()),
|
||||
used: 0,
|
||||
name,
|
||||
}
|
||||
@ -33,7 +33,7 @@ impl Slots {
|
||||
}
|
||||
}
|
||||
fn init(&mut self, name: &'static str, size: usize) {
|
||||
self.bits = Some(bitvec![Lsb0, u8; 0; size].into_boxed_bitslice());
|
||||
self.bits = Some(bitvec![u8, Lsb0; 0; size].into_boxed_bitslice());
|
||||
self.name = name;
|
||||
}
|
||||
fn used_slots(&self) -> usize { self.used }
|
||||
@ -57,11 +57,11 @@ impl Slots {
|
||||
let bslice = &mut bits.as_mut_bitslice()[range];
|
||||
if value {
|
||||
assert!(bslice.not_any());
|
||||
bslice.set_all(true);
|
||||
bslice.fill(true);
|
||||
self.used = self.used + count;
|
||||
} else {
|
||||
assert!(bslice.all());
|
||||
bslice.set_all(false);
|
||||
bslice.fill(false);
|
||||
self.used = self.used - count;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user