macro_rules! span_of {
($($tt:tt)*) => { ... };
}
Expand description
Returns the start..end
offsets of a field.
#[repr(C)]
struct Data {
byte: u8,
float: f32,
}
let span = dataview::span_of!(Data.float);
assert_eq!(span, 4..8);
assert_eq!(span.len(), 4);
const SPAN: std::ops::Range<usize> = dataview::span_of!(Data.float);
assert_eq!(SPAN, 4..8);
assert_eq!(SPAN.len(), 4);
The syntax is $ty.$field
.
No support for tuples, tuple structs or unions.
No support for projecting through multiple fields.