Unverified Commit 33a64124 authored by Keith Yeung's avatar Keith Yeung
Browse files

Fix compilation errors with bit_vec.rs

parent 682e622a
Pipeline #153884 failed with stages
in 22 minutes and 17 seconds
......@@ -14,9 +14,7 @@
//! `BitVec` specific serialization.
use bitvec::{
vec::BitVec, store::BitStore, order::BitOrder, slice::BitSlice, boxed::BitBox, mem::BitMemory
};
use bitvec::{vec::BitVec, store::BitStore, order::BitOrder, slice::BitSlice, boxed::BitBox};
use crate::{
EncodeLike, Encode, Decode, Input, Output, Error, Compact,
codec::{decode_vec_with_len, encode_slice_no_len},
......@@ -31,11 +29,11 @@ impl<O: BitOrder, T: BitStore + Encode> Encode for BitSlice<O, T> {
);
Compact(len as u32).encode_to(dest);
// NOTE: doc of `BitSlice::as_slice`:
// NOTE: doc of `BitSlice::as_raw_slice`:
// > The returned slice handle views all elements touched by self
//
// Thus we are sure the slice doesn't contain unused elements at the end.
let slice = self.as_slice();
let slice = self.as_raw_slice();
encode_slice_no_len(slice, dest)
}
......@@ -97,7 +95,7 @@ impl<O: BitOrder, T: BitStore + Decode> Decode for BitBox<O, T> {
/// NOTE: this should never happen if `bits` is already checked to be less than
/// `BitStore::MAX_BITS`.
fn required_elements<T: BitStore>(bits: u32) -> Result<u32, Error> {
let element_bits = T::Mem::BITS as u32;
let element_bits = core::mem::size_of::<T::Mem>() as u32 * 8;
let error = Error::from("Attempt to decode bitvec with too many bits");
Ok((bits.checked_add(element_bits).ok_or_else(|| error)? - 1) / element_bits)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment