Coverage Report

Created: 2025-07-18 06:16

/rust/registry/src/index.crates.io-6f17d22bba15001f/bitvec-1.0.1/src/devel.rs
Line
Count
Source (jump to first uncovered line)
1
//! Support utilities for crate development.
2
3
use core::any::TypeId;
4
5
use crate::{
6
  order::BitOrder,
7
  store::BitStore,
8
};
9
10
/// Constructs formatting-trait implementations by delegating.
11
macro_rules! easy_fmt {
12
  ($(impl $fmt:ident)+ for BitArray) => { $(
13
    impl<A, O> core::fmt::$fmt for $crate::array::BitArray<A, O>
14
    where
15
      O: $crate::order::BitOrder,
16
      A: $crate::view::BitViewSized,
17
    {
18
      #[inline]
19
      #[cfg(not(tarpaulin_include))]
20
0
      fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
21
0
        core::fmt::$fmt::fmt(self.as_bitslice(), fmt)
22
0
      }
Unexecuted instantiation: <bitvec::array::BitArray<_, _> as core::fmt::Binary>::fmt
Unexecuted instantiation: <bitvec::array::BitArray<_, _> as core::fmt::Display>::fmt
Unexecuted instantiation: <bitvec::array::BitArray<_, _> as core::fmt::LowerHex>::fmt
Unexecuted instantiation: <bitvec::array::BitArray<_, _> as core::fmt::Octal>::fmt
Unexecuted instantiation: <bitvec::array::BitArray<_, _> as core::fmt::UpperHex>::fmt
23
    }
24
  )+ };
25
  ($(impl $fmt:ident)+ for $this:ident) => { $(
26
    impl<T, O> core::fmt::$fmt for $this<T, O>
27
    where
28
      O: $crate::order::BitOrder,
29
      T: $crate::store::BitStore,
30
    {
31
      #[inline]
32
      #[cfg(not(tarpaulin_include))]
33
0
      fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
34
0
        core::fmt::$fmt::fmt(self.as_bitslice(), fmt)
35
0
      }
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::Binary>::fmt
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::Display>::fmt
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::LowerHex>::fmt
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::Octal>::fmt
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::Pointer>::fmt
Unexecuted instantiation: <bitvec::boxed::BitBox<_, _> as core::fmt::UpperHex>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::Binary>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::Display>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::LowerHex>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::Octal>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::Pointer>::fmt
Unexecuted instantiation: <bitvec::vec::BitVec<_, _> as core::fmt::UpperHex>::fmt
36
    }
37
  )+ };
38
}
39
40
/// Implements some `Iterator` functions that have boilerplate behavior.
41
macro_rules! easy_iter {
42
  () => {
43
    #[inline]
44
0
    fn size_hint(&self) -> (usize, Option<usize>) {
45
0
      let len = self.len();
46
0
      (len, Some(len))
47
0
    }
Unexecuted instantiation: <bitvec::array::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::boxed::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::ptr::range::BitPtrRange<_, _, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::Iter<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::IterMut<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::BitValIter<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::Windows<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::Chunks<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::ChunksMut<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::ChunksExact<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::ChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::RChunks<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::RChunksMut<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::RChunksExact<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::RChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::IterOnes<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::slice::iter::IterZeros<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::vec::iter::Drain<_, _> as core::iter::traits::iterator::Iterator>::size_hint
Unexecuted instantiation: <bitvec::vec::iter::Splice<_, _, _> as core::iter::traits::iterator::Iterator>::size_hint
48
49
    #[inline]
50
0
    fn count(self) -> usize {
51
0
      self.len()
52
0
    }
Unexecuted instantiation: <bitvec::array::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::boxed::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::ptr::range::BitPtrRange<_, _, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::Iter<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::IterMut<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::BitValIter<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::Windows<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::Chunks<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::ChunksMut<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::ChunksExact<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::ChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::RChunks<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::RChunksMut<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::RChunksExact<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::RChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::IterOnes<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::slice::iter::IterZeros<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::vec::iter::Drain<_, _> as core::iter::traits::iterator::Iterator>::count
Unexecuted instantiation: <bitvec::vec::iter::Splice<_, _, _> as core::iter::traits::iterator::Iterator>::count
53
54
    #[inline]
55
0
    fn last(mut self) -> Option<Self::Item> {
56
0
      self.next_back()
57
0
    }
Unexecuted instantiation: <bitvec::array::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::boxed::iter::IntoIter<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::ptr::range::BitPtrRange<_, _, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::Iter<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::IterMut<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::BitValIter<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::Windows<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::Chunks<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::ChunksMut<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::ChunksExact<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::ChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::RChunks<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::RChunksMut<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::RChunksExact<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::RChunksExactMut<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::IterOnes<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::slice::iter::IterZeros<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::vec::iter::Drain<_, _> as core::iter::traits::iterator::Iterator>::last
Unexecuted instantiation: <bitvec::vec::iter::Splice<_, _, _> as core::iter::traits::iterator::Iterator>::last
58
  };
59
}
60
61
/// Tests if two `BitOrder` implementors are the same.
62
#[inline]
63
260k
pub fn match_order<O, P>() -> bool
64
260k
where
65
260k
  O: BitOrder,
66
260k
  P: BitOrder,
67
260k
{
68
260k
  eq_types::<O, P>()
69
260k
}
bitvec::devel::match_order::<bitvec::order::Msb0, bitvec::order::Msb0>
Line
Count
Source
63
130k
pub fn match_order<O, P>() -> bool
64
130k
where
65
130k
  O: BitOrder,
66
130k
  P: BitOrder,
67
130k
{
68
130k
  eq_types::<O, P>()
69
130k
}
bitvec::devel::match_order::<bitvec::order::Msb0, bitvec::order::Lsb0>
Line
Count
Source
63
130k
pub fn match_order<O, P>() -> bool
64
130k
where
65
130k
  O: BitOrder,
66
130k
  P: BitOrder,
67
130k
{
68
130k
  eq_types::<O, P>()
69
130k
}
Unexecuted instantiation: bitvec::devel::match_order::<_, _>
70
71
/// Tests if two `BitStore` implementors are the same.
72
#[inline]
73
130k
pub fn match_store<T, U>() -> bool
74
130k
where
75
130k
  T: BitStore,
76
130k
  U: BitStore,
77
130k
{
78
130k
  eq_types::<T, U>()
79
130k
}
bitvec::devel::match_store::<u8, u8>
Line
Count
Source
73
130k
pub fn match_store<T, U>() -> bool
74
130k
where
75
130k
  T: BitStore,
76
130k
  U: BitStore,
77
130k
{
78
130k
  eq_types::<T, U>()
79
130k
}
Unexecuted instantiation: bitvec::devel::match_store::<_, _>
80
81
/// Tests if two `BitSlice` type parameter pairs match each other.
82
#[inline]
83
260k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
260k
where
85
260k
  O1: BitOrder,
86
260k
  T1: BitStore,
87
260k
  O2: BitOrder,
88
260k
  T2: BitStore,
89
260k
{
90
260k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
260k
}
bitvec::devel::match_types::<u8, bitvec::order::Msb0, u8, bitvec::order::Msb0>
Line
Count
Source
83
130k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
130k
where
85
130k
  O1: BitOrder,
86
130k
  T1: BitStore,
87
130k
  O2: BitOrder,
88
130k
  T2: BitStore,
89
130k
{
90
130k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
130k
}
bitvec::devel::match_types::<u8, bitvec::order::Msb0, u8, bitvec::order::Lsb0>
Line
Count
Source
83
130k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
130k
where
85
130k
  O1: BitOrder,
86
130k
  T1: BitStore,
87
130k
  O2: BitOrder,
88
130k
  T2: BitStore,
89
130k
{
90
130k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
130k
}
Unexecuted instantiation: bitvec::devel::match_types::<_, _, _, _>
92
93
/// Tests if a type is known to be an unsigned integer.
94
///
95
/// Returns `true` for `u{8,16,32,64,128,size}` and `false` for all others.
96
#[inline]
97
135k
pub fn is_unsigned<T>() -> bool
98
135k
where T: 'static {
99
135k
  eq_types::<T, u8>()
100
135k
    || eq_types::<T, u16>()
101
132k
    || eq_types::<T, u32>()
102
132k
    || eq_types::<T, u64>()
103
132k
    || eq_types::<T, u128>()
104
94.4k
    || eq_types::<T, usize>()
105
135k
}
bitvec::devel::is_unsigned::<usize>
Line
Count
Source
97
94.4k
pub fn is_unsigned<T>() -> bool
98
94.4k
where T: 'static {
99
94.4k
  eq_types::<T, u8>()
100
94.4k
    || eq_types::<T, u16>()
101
94.4k
    || eq_types::<T, u32>()
102
94.4k
    || eq_types::<T, u64>()
103
94.4k
    || eq_types::<T, u128>()
104
94.4k
    || eq_types::<T, usize>()
105
94.4k
}
bitvec::devel::is_unsigned::<u128>
Line
Count
Source
97
38.3k
pub fn is_unsigned<T>() -> bool
98
38.3k
where T: 'static {
99
38.3k
  eq_types::<T, u8>()
100
38.3k
    || eq_types::<T, u16>()
101
38.3k
    || eq_types::<T, u32>()
102
38.3k
    || eq_types::<T, u64>()
103
38.3k
    || eq_types::<T, u128>()
104
0
    || eq_types::<T, usize>()
105
38.3k
}
bitvec::devel::is_unsigned::<u16>
Line
Count
Source
97
2.31k
pub fn is_unsigned<T>() -> bool
98
2.31k
where T: 'static {
99
2.31k
  eq_types::<T, u8>()
100
2.31k
    || eq_types::<T, u16>()
101
0
    || eq_types::<T, u32>()
102
0
    || eq_types::<T, u64>()
103
0
    || eq_types::<T, u128>()
104
0
    || eq_types::<T, usize>()
105
2.31k
}
Unexecuted instantiation: bitvec::devel::is_unsigned::<_>
106
107
/// Tests if two types are identical, even through different names.
108
#[inline]
109
1.15M
fn eq_types<T, U>() -> bool
110
1.15M
where
111
1.15M
  T: 'static,
112
1.15M
  U: 'static,
113
1.15M
{
114
1.15M
  TypeId::of::<T>() == TypeId::of::<U>()
115
1.15M
}
bitvec::devel::eq_types::<bitvec::order::Msb0, bitvec::order::Msb0>
Line
Count
Source
109
130k
fn eq_types<T, U>() -> bool
110
130k
where
111
130k
  T: 'static,
112
130k
  U: 'static,
113
130k
{
114
130k
  TypeId::of::<T>() == TypeId::of::<U>()
115
130k
}
bitvec::devel::eq_types::<bitvec::order::Msb0, bitvec::order::Lsb0>
Line
Count
Source
109
130k
fn eq_types<T, U>() -> bool
110
130k
where
111
130k
  T: 'static,
112
130k
  U: 'static,
113
130k
{
114
130k
  TypeId::of::<T>() == TypeId::of::<U>()
115
130k
}
bitvec::devel::eq_types::<u8, u8>
Line
Count
Source
109
130k
fn eq_types<T, U>() -> bool
110
130k
where
111
130k
  T: 'static,
112
130k
  U: 'static,
113
130k
{
114
130k
  TypeId::of::<T>() == TypeId::of::<U>()
115
130k
}
bitvec::devel::eq_types::<usize, u8>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<usize, usize>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<usize, u32>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<usize, u128>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<usize, u16>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<usize, u64>
Line
Count
Source
109
94.4k
fn eq_types<T, U>() -> bool
110
94.4k
where
111
94.4k
  T: 'static,
112
94.4k
  U: 'static,
113
94.4k
{
114
94.4k
  TypeId::of::<T>() == TypeId::of::<U>()
115
94.4k
}
bitvec::devel::eq_types::<u128, u8>
Line
Count
Source
109
38.3k
fn eq_types<T, U>() -> bool
110
38.3k
where
111
38.3k
  T: 'static,
112
38.3k
  U: 'static,
113
38.3k
{
114
38.3k
  TypeId::of::<T>() == TypeId::of::<U>()
115
38.3k
}
Unexecuted instantiation: bitvec::devel::eq_types::<u128, usize>
bitvec::devel::eq_types::<u128, u32>
Line
Count
Source
109
38.3k
fn eq_types<T, U>() -> bool
110
38.3k
where
111
38.3k
  T: 'static,
112
38.3k
  U: 'static,
113
38.3k
{
114
38.3k
  TypeId::of::<T>() == TypeId::of::<U>()
115
38.3k
}
bitvec::devel::eq_types::<u128, u128>
Line
Count
Source
109
38.3k
fn eq_types<T, U>() -> bool
110
38.3k
where
111
38.3k
  T: 'static,
112
38.3k
  U: 'static,
113
38.3k
{
114
38.3k
  TypeId::of::<T>() == TypeId::of::<U>()
115
38.3k
}
bitvec::devel::eq_types::<u128, u16>
Line
Count
Source
109
38.3k
fn eq_types<T, U>() -> bool
110
38.3k
where
111
38.3k
  T: 'static,
112
38.3k
  U: 'static,
113
38.3k
{
114
38.3k
  TypeId::of::<T>() == TypeId::of::<U>()
115
38.3k
}
bitvec::devel::eq_types::<u128, u64>
Line
Count
Source
109
38.3k
fn eq_types<T, U>() -> bool
110
38.3k
where
111
38.3k
  T: 'static,
112
38.3k
  U: 'static,
113
38.3k
{
114
38.3k
  TypeId::of::<T>() == TypeId::of::<U>()
115
38.3k
}
bitvec::devel::eq_types::<u16, u8>
Line
Count
Source
109
2.31k
fn eq_types<T, U>() -> bool
110
2.31k
where
111
2.31k
  T: 'static,
112
2.31k
  U: 'static,
113
2.31k
{
114
2.31k
  TypeId::of::<T>() == TypeId::of::<U>()
115
2.31k
}
Unexecuted instantiation: bitvec::devel::eq_types::<u16, usize>
Unexecuted instantiation: bitvec::devel::eq_types::<u16, u32>
Unexecuted instantiation: bitvec::devel::eq_types::<u16, u128>
bitvec::devel::eq_types::<u16, u16>
Line
Count
Source
109
2.31k
fn eq_types<T, U>() -> bool
110
2.31k
where
111
2.31k
  T: 'static,
112
2.31k
  U: 'static,
113
2.31k
{
114
2.31k
  TypeId::of::<T>() == TypeId::of::<U>()
115
2.31k
}
Unexecuted instantiation: bitvec::devel::eq_types::<u16, u64>
Unexecuted instantiation: bitvec::devel::eq_types::<_, _>