|
let daddr = data.get_unchecked(0); |
get_unchecked(0) will panic in dev build, if that slice is empty.
thread 'main' panicked at library/core/src/panicking.rs:215:5:
unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice
stack backtrace:
0: rust_begin_unwind
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/std/src/panicking.rs:645:5
1: core::panicking::panic_nounwind_fmt::runtime
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/panicking.rs:110:18
2: core::panicking::panic_nounwind_fmt
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/panicking.rs:120:5
3: core::panicking::panic_nounwind
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/panicking.rs:215:5
4: <usize as core::slice::index::SliceIndex<[T]>>::get_unchecked::precondition_check
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/ub_checks.rs:66:21
5: <usize as core::slice::index::SliceIndex<[T]>>::get_unchecked
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/slice/index.rs:218:9
6: core::slice::<impl [T]>::get_unchecked
at /rustc/becebb3158149a115cad8a402612e25436a7e37b/library/core/src/slice/mod.rs:686:20
7: compression::cbuffer::CircularBuffer<T>::append
at ./third_party/rust-compression/src/cbuffer.rs:39:25
8: <compression::bitio::reader::BitReader<D> as compression::bitio::reader::BitRead>::peek_bits
at ./third_party/rust-compression/src/bitio/reader.rs:95:17
9: compression::bzip2::decoder::BZip2DecoderBase::init_block
I think instead of that using as_ptr should be fine.
rust-compression/src/cbuffer.rs
Line 39 in 62afc98
get_unchecked(0) will panic in dev build, if that slice is empty.
I think instead of that using
as_ptrshould be fine.