I was worried because rustdoc didn't show the values for the enum variants.
Does stable
refer to the particular integer representation as well as the name of the enum variant?
That would mean,
#[stable(feature = "rust1", since = "1.0.0")]
#[repr(i8)]
pub enum Ordering {
Here, stable
refers to enum Ordering
but not to the repr
annotation?
My use case is the following:
unsafe extern "C" fn compare_function<T>(a: *const lmdb::MDB_val, b: *const lmdb::MDB_val) -> c_int
where
T: ?Sized + Storable,
{
let a: &[u8] =
slice::from_raw_parts((*a).mv_data as *const u8, (*a).mv_size.try_into().unwrap());
let b: &[u8] =
slice::from_raw_parts((*b).mv_data as *const u8, (*b).mv_size.try_into().unwrap());
match T::cmp_bytes_unchecked(a, b) {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1,
}
}