bitvec/array/api.rs
1#![doc = include_str!("../../doc/array/api.md")]
2
3use super::BitArray;
4use crate::{
5 order::BitOrder,
6 slice::BitSlice,
7 view::BitViewSized,
8};
9
10impl<A, O> BitArray<A, O>
11where
12 A: BitViewSized,
13 O: BitOrder,
14{
15 /// Returns a bit-slice containing the entire bit-array. Equivalent to
16 /// `&a[..]`.
17 ///
18 /// Because `BitArray` can be viewed as a slice of bits or as a slice of
19 /// elements with equal ease, you should switch to using [`.as_bitslice()`]
20 /// or [`.as_raw_slice()`] to make your choice explicit.
21 ///
22 /// ## Original
23 ///
24 /// [`array::as_slice`](https://doc.rust-lang.org/std/primitive.array.html#method.as_slice)
25 ///
26 /// [`.as_bitslice()`]: Self::as_bitslice
27 /// [`.as_raw_slice()`]: Self::as_raw_slice
28 #[inline]
29 #[cfg(not(tarpaulin_include))]
30 #[deprecated = "use `.as_bitslice()` or `.as_raw_slice()` instead"]
31 pub fn as_slice(&self) -> &BitSlice<A::Store, O> {
32 self.as_bitslice()
33 }
34
35 /// Returns a mutable bit-slice containing the entire bit-array. Equivalent
36 /// to `&mut a[..]`.
37 ///
38 /// Because `BitArray` can be viewed as a slice of bits or as a slice of
39 /// elements with equal ease, you should switch to using
40 /// [`.as_mut_bitslice()`] or [`.as_raw_mut_slice()`] to make your choice
41 /// explicit.
42 ///
43 /// ## Original
44 ///
45 /// [`array::as_mut_slice`](https://doc.rust-lang.org/std/primitive.array.html#method.as_mut_slice)
46 ///
47 /// [`.as_mut_bitslice()`]: Self::as_mut_bitslice
48 /// [`.as_raw_mut_slice()`]: Self::as_raw_mut_slice
49 #[inline]
50 #[cfg(not(tarpaulin_include))]
51 #[deprecated = "use `.as_mut_bitslice()` or `.as_raw_mut_slice()` instead"]
52 pub fn as_mut_slice(&mut self) -> &mut BitSlice<A::Store, O> {
53 self.as_mut_bitslice()
54 }
55}