Module bytecast

Source
Expand description

Trivial, internal byte transmutation.

A dependency like bytemuck would give us extra assurance of the safety but overall would not reduce the amount of total unsafety. We don’t use it in the interface where the traits would really become useful.

SAFETY: These are benign casts as we apply them to fixed size integer types only. All of them are naturally aligned, valid for all bit patterns and their alignment is surely at most their size (we assert the latter fact since it is β€˜implementation defined’ if following the letter of the unsafe code guidelines).

TODO: Would like to use std-lib here.

MacrosΒ§

integral_slice_as_bytes πŸ”’

FunctionsΒ§

f32_as_ne_bytes πŸ”’
f32_as_ne_mut_bytes πŸ”’
f64_as_ne_bytes πŸ”’
f64_as_ne_mut_bytes πŸ”’
i8_as_ne_bytes πŸ”’
i8_as_ne_mut_bytes πŸ”’
i16_as_ne_bytes πŸ”’
i16_as_ne_mut_bytes πŸ”’
i32_as_ne_bytes πŸ”’
i32_as_ne_mut_bytes πŸ”’
i64_as_ne_bytes πŸ”’
i64_as_ne_mut_bytes πŸ”’
u16_as_ne_bytes πŸ”’
u16_as_ne_mut_bytes πŸ”’
u32_as_ne_bytes πŸ”’
u32_as_ne_mut_bytes πŸ”’
u64_as_ne_bytes πŸ”’
u64_as_ne_mut_bytes πŸ”’