Macro qed::const_assert_bytes_has_no_nul

source ·
macro_rules! const_assert_bytes_has_no_nul {
    ($bytes:expr $(,)?) => { ... };
}
Expand description

Asserts that a byte slice does not contain any NUL (\0) bytes.

This macro emits a compile error if the given slice contains any NUL bytes, including a NUL terminator.

§Examples

const ARRAY_CLASS: &[u8] = b"Array";
qed::const_assert_bytes_has_no_nul!(ARRAY_CLASS);

The following fails to compile because the byte slice contains a NUL byte:

const BYTES: &[u8] = b"abc\0xyz";
qed::const_assert_bytes_has_no_nul!(BYTES);

The following fails to compile because the byte slice contains a NUL terminator:

const CSTR: &[u8] = b"Q.E.D.\x00";
qed::const_assert_bytes_has_no_nul!(CSTR);