Function safe_transmute::base::transmute_many_permissive[][src]

pub unsafe fn transmute_many_permissive<T>(bytes: &[u8]) -> &[T]

View a byte slice as a slice of an arbitrary type.

The resulting slice will have as many instances of a type as will fit, rounded down. The permissive guard is a no-op, which makes it possible for this function to return a slice directly. It is therefore equivalent to transmute_many::<_, PermissiveGuard>(bytes).unwrap().

Safety

Failure to fulfill any of the requirements above may result in undefined behavior.

Examples

// Little-endian
unsafe {
    assert_eq!(
        transmute_many_permissive::<u16>(&[0x00, 0x01, 0x00, 0x02]),
        &[0x0100, 0x0200]
    );
}