Skip to content

Commit e05fc2f

Browse files
committed
Hold work
1 parent abedb0e commit e05fc2f

11 files changed

Lines changed: 819 additions & 420 deletions

File tree

src/index.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ where R: BitRegister
179179
}
180180
}
181181

182+
/// Casts to a new index type.
183+
///
184+
/// This will always succeed if `self.value()` is a valid index in the `S`
185+
/// register; it will return an error if the `self` index is too wide for
186+
/// `S`.
187+
pub fn cast<S>(self) -> Result<BitIdx<S>, BitIdxErr<S>>
188+
where S: BitRegister {
189+
BitIdx::new(self.value())
190+
}
191+
182192
/// Removes the index wrapper, leaving the internal counter.
183193
#[cfg(not(tarpaulin_include))]
184194
pub fn value(self) -> u8 {
@@ -1224,10 +1234,7 @@ where R: BitRegister
12241234
#[cfg(test)]
12251235
mod tests {
12261236
use super::*;
1227-
use crate::order::{
1228-
Lsb0,
1229-
Msb0,
1230-
};
1237+
use crate::order::Lsb0;
12311238
use tap::conv::TryConv;
12321239

12331240
#[test]
@@ -1488,6 +1495,8 @@ mod tests {
14881495
#[test]
14891496
#[cfg(feature = "alloc")]
14901497
fn render() {
1498+
use crate::order::Msb0;
1499+
14911500
#[cfg(not(feature = "std"))]
14921501
use alloc::format;
14931502

src/prelude.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub use crate::{
1717
Lsb0,
1818
Msb0,
1919
},
20+
ptr::{
21+
BitPtr,
22+
BitPtrRange,
23+
},
2024
slice::BitSlice,
2125
store::BitStore,
2226
view::BitView,

0 commit comments

Comments
 (0)