How to convert BitVec/BitSlice to u8?

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

https://docs.rs/bitvec/0.22.3/bitvec

//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

EDIT:

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.