icu4x
icu4x copied to clipboard
ULE trait should work on not just slices
This issue is intended to be discussed in the context of zerovec 1.0 / holistic design
I've thought this for a while but I wasn't able to find an issue for it. The trait is currently:
pub unsafe trait ULE
where
Self: Sized + Copy + 'static,
{
// Required method
fn validate_byte_slice(bytes: &[u8]) -> Result<(), UleError>;
// Provided methods
fn parse_byte_slice(bytes: &[u8]) -> Result<&[Self], UleError> { ... }
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &[Self] { ... }
fn as_byte_slice(slice: &[Self]) -> &[u8] { ... }
}
I think we should add:
validate_chunk(chunk: [u8; size_of::<Self>]) -> Result<(), UleError>(required method)parse_chunk(provided method)from_chunk_unchecked(provided method)
and then change validate_byte_slice to be a provided method.