How to convert BitVec/BitSlice to u8?

How to convert a BitVec/BitSlice to u8?
I can't find a solution.

//use bitvec = "0.22.3"
use std::ops::Range;
use bitvec::prelude::BitVec;
use bitvec::order::{LocalBits, Lsb0};
use bitvec::view::BitView;

let can_id: u32 = 0x1700E24B;
let can_id_bits = can_id.view_bits::<Lsb0>().to_bitvec();
println!("can_id_bits: {:?}", can_id_bits);

let r : Range<usize> = 0..4;
let field = can_id_bits.get(r).unwrap();
println!("field: {:?}", field);

// How to convert  - ft  -> u8


I'm solved:

let value_u8 = field.load::<u8>();

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.