Function konst::slice::cmp::cmp_slice_u8

source ·
pub const fn cmp_slice_u8<'a>(left: &[u8], right: &[u8]) -> Ordering
Expand description

Compares two &[u8], returning the order of left relative to right.

§Example

use konst::slice::cmp_bytes;

use std::cmp::Ordering;

const FOO: &[u8] = b"foo";
const BAR: &[u8] = b"fooooo";
const BAZ: &[u8] = b"bar";


const FOO_CMP_FOO: Ordering = cmp_bytes(FOO, FOO);
assert_eq!(FOO_CMP_FOO, Ordering::Equal);

const FOO_CMP_BAR: Ordering = cmp_bytes(FOO, BAR);
assert_eq!(FOO_CMP_BAR, Ordering::Less);

const FOO_CMP_BAZ: Ordering = cmp_bytes(FOO, BAZ);
assert_eq!(FOO_CMP_BAZ, Ordering::Greater);