Coverage Report

Created: 2025-07-01 06:28

/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
145k
pub fn match_order<O, P>() -> bool
64
145k
where
65
145k
  O: BitOrder,
66
145k
  P: BitOrder,
67
145k
{
68
145k
  eq_types::<O, P>()
69
145k
}
bitvec::devel::match_order::<bitvec::order::Msb0, bitvec::order::Msb0>
Line
Count
Source
63
72.6k
pub fn match_order<O, P>() -> bool
64
72.6k
where
65
72.6k
  O: BitOrder,
66
72.6k
  P: BitOrder,
67
72.6k
{
68
72.6k
  eq_types::<O, P>()
69
72.6k
}
bitvec::devel::match_order::<bitvec::order::Msb0, bitvec::order::Lsb0>
Line
Count
Source
63
72.6k
pub fn match_order<O, P>() -> bool
64
72.6k
where
65
72.6k
  O: BitOrder,
66
72.6k
  P: BitOrder,
67
72.6k
{
68
72.6k
  eq_types::<O, P>()
69
72.6k
}
Unexecuted instantiation: bitvec::devel::match_order::<_, _>
70
71
/// Tests if two `BitStore` implementors are the same.
72
#[inline]
73
72.6k
pub fn match_store<T, U>() -> bool
74
72.6k
where
75
72.6k
  T: BitStore,
76
72.6k
  U: BitStore,
77
72.6k
{
78
72.6k
  eq_types::<T, U>()
79
72.6k
}
bitvec::devel::match_store::<u8, u8>
Line
Count
Source
73
72.6k
pub fn match_store<T, U>() -> bool
74
72.6k
where
75
72.6k
  T: BitStore,
76
72.6k
  U: BitStore,
77
72.6k
{
78
72.6k
  eq_types::<T, U>()
79
72.6k
}
Unexecuted instantiation: bitvec::devel::match_store::<_, _>
80
81
/// Tests if two `BitSlice` type parameter pairs match each other.
82
#[inline]
83
145k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
145k
where
85
145k
  O1: BitOrder,
86
145k
  T1: BitStore,
87
145k
  O2: BitOrder,
88
145k
  T2: BitStore,
89
145k
{
90
145k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
145k
}
bitvec::devel::match_types::<u8, bitvec::order::Msb0, u8, bitvec::order::Msb0>
Line
Count
Source
83
72.6k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
72.6k
where
85
72.6k
  O1: BitOrder,
86
72.6k
  T1: BitStore,
87
72.6k
  O2: BitOrder,
88
72.6k
  T2: BitStore,
89
72.6k
{
90
72.6k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
72.6k
}
bitvec::devel::match_types::<u8, bitvec::order::Msb0, u8, bitvec::order::Lsb0>
Line
Count
Source
83
72.6k
pub fn match_types<T1, O1, T2, O2>() -> bool
84
72.6k
where
85
72.6k
  O1: BitOrder,
86
72.6k
  T1: BitStore,
87
72.6k
  O2: BitOrder,
88
72.6k
  T2: BitStore,
89
72.6k
{
90
72.6k
  match_order::<O1, O2>() && match_store::<T1, T2>()
91
72.6k
}
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
75.0k
pub fn is_unsigned<T>() -> bool
98
75.0k
where T: 'static {
99
75.0k
  eq_types::<T, u8>()
100
75.0k
    || eq_types::<T, u16>()
101
73.9k
    || eq_types::<T, u32>()
102
73.9k
    || eq_types::<T, u64>()
103
73.9k
    || eq_types::<T, u128>()
104
52.6k
    || eq_types::<T, usize>()
105
75.0k
}
bitvec::devel::is_unsigned::<usize>
Line
Count
Source
97
52.6k
pub fn is_unsigned<T>() -> bool
98
52.6k
where T: 'static {
99
52.6k
  eq_types::<T, u8>()
100
52.6k
    || eq_types::<T, u16>()
101
52.6k
    || eq_types::<T, u32>()
102
52.6k
    || eq_types::<T, u64>()
103
52.6k
    || eq_types::<T, u128>()
104
52.6k
    || eq_types::<T, usize>()
105
52.6k
}
bitvec::devel::is_unsigned::<u128>
Line
Count
Source
97
21.2k
pub fn is_unsigned<T>() -> bool
98
21.2k
where T: 'static {
99
21.2k
  eq_types::<T, u8>()
100
21.2k
    || eq_types::<T, u16>()
101
21.2k
    || eq_types::<T, u32>()
102
21.2k
    || eq_types::<T, u64>()
103
21.2k
    || eq_types::<T, u128>()
104
0
    || eq_types::<T, usize>()
105
21.2k
}
bitvec::devel::is_unsigned::<u16>
Line
Count
Source
97
1.15k
pub fn is_unsigned<T>() -> bool
98
1.15k
where T: 'static {
99
1.15k
  eq_types::<T, u8>()
100
1.15k
    || 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
1.15k
}
Unexecuted instantiation: bitvec::devel::is_unsigned::<_>
106
107
/// Tests if two types are identical, even through different names.
108
#[inline]
109
642k
fn eq_types<T, U>() -> bool
110
642k
where
111
642k
  T: 'static,
112
642k
  U: 'static,
113
642k
{
114
642k
  TypeId::of::<T>() == TypeId::of::<U>()
115
642k
}
bitvec::devel::eq_types::<bitvec::order::Msb0, bitvec::order::Msb0>
Line
Count
Source
109
72.6k
fn eq_types<T, U>() -> bool
110
72.6k
where
111
72.6k
  T: 'static,
112
72.6k
  U: 'static,
113
72.6k
{
114
72.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
72.6k
}
bitvec::devel::eq_types::<bitvec::order::Msb0, bitvec::order::Lsb0>
Line
Count
Source
109
72.6k
fn eq_types<T, U>() -> bool
110
72.6k
where
111
72.6k
  T: 'static,
112
72.6k
  U: 'static,
113
72.6k
{
114
72.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
72.6k
}
bitvec::devel::eq_types::<u8, u8>
Line
Count
Source
109
72.6k
fn eq_types<T, U>() -> bool
110
72.6k
where
111
72.6k
  T: 'static,
112
72.6k
  U: 'static,
113
72.6k
{
114
72.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
72.6k
}
bitvec::devel::eq_types::<usize, u8>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<usize, usize>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<usize, u32>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<usize, u128>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<usize, u16>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<usize, u64>
Line
Count
Source
109
52.6k
fn eq_types<T, U>() -> bool
110
52.6k
where
111
52.6k
  T: 'static,
112
52.6k
  U: 'static,
113
52.6k
{
114
52.6k
  TypeId::of::<T>() == TypeId::of::<U>()
115
52.6k
}
bitvec::devel::eq_types::<u128, u8>
Line
Count
Source
109
21.2k
fn eq_types<T, U>() -> bool
110
21.2k
where
111
21.2k
  T: 'static,
112
21.2k
  U: 'static,
113
21.2k
{
114
21.2k
  TypeId::of::<T>() == TypeId::of::<U>()
115
21.2k
}
Unexecuted instantiation: bitvec::devel::eq_types::<u128, usize>
bitvec::devel::eq_types::<u128, u32>
Line
Count
Source
109
21.2k
fn eq_types<T, U>() -> bool
110
21.2k
where
111
21.2k
  T: 'static,
112
21.2k
  U: 'static,
113
21.2k
{
114
21.2k
  TypeId::of::<T>() == TypeId::of::<U>()
115
21.2k
}
bitvec::devel::eq_types::<u128, u128>
Line
Count
Source
109
21.2k
fn eq_types<T, U>() -> bool
110
21.2k
where
111
21.2k
  T: 'static,
112
21.2k
  U: 'static,
113
21.2k
{
114
21.2k
  TypeId::of::<T>() == TypeId::of::<U>()
115
21.2k
}
bitvec::devel::eq_types::<u128, u16>
Line
Count
Source
109
21.2k
fn eq_types<T, U>() -> bool
110
21.2k
where
111
21.2k
  T: 'static,
112
21.2k
  U: 'static,
113
21.2k
{
114
21.2k
  TypeId::of::<T>() == TypeId::of::<U>()
115
21.2k
}
bitvec::devel::eq_types::<u128, u64>
Line
Count
Source
109
21.2k
fn eq_types<T, U>() -> bool
110
21.2k
where
111
21.2k
  T: 'static,
112
21.2k
  U: 'static,
113
21.2k
{
114
21.2k
  TypeId::of::<T>() == TypeId::of::<U>()
115
21.2k
}
bitvec::devel::eq_types::<u16, u8>
Line
Count
Source
109
1.15k
fn eq_types<T, U>() -> bool
110
1.15k
where
111
1.15k
  T: 'static,
112
1.15k
  U: 'static,
113
1.15k
{
114
1.15k
  TypeId::of::<T>() == TypeId::of::<U>()
115
1.15k
}
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
1.15k
fn eq_types<T, U>() -> bool
110
1.15k
where
111
1.15k
  T: 'static,
112
1.15k
  U: 'static,
113
1.15k
{
114
1.15k
  TypeId::of::<T>() == TypeId::of::<U>()
115
1.15k
}
Unexecuted instantiation: bitvec::devel::eq_types::<u16, u64>
Unexecuted instantiation: bitvec::devel::eq_types::<_, _>