Skip to content

Add some const constructors for ULE slices for ZeroVec #1647

Open
@sffc

Description

@sffc

In #1644, @makotokato is trying to produce a ZeroVec from include_bytes!(). Currently he uses a transmute to coerce the bytes into a ULE slice. This is not logic that should have to live at the call site.

I think we can't use parse_byte_slice because it's a trait function, which is unfortunate. However, we can solve this on a case-by-case basis by adding const constructors, like

const FOO: &[u16::ULE; 100] = u16::ULE::from_byte_array_const(
    include_bytes!("...")
)
.expect("all bytes are valid for u16::ULE");

CC @Manishearth

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-zerovecComponent: Yoke, ZeroVec, DataBakeT-techdebtType: ICU4X code health and tech debtblockedA dependency must be resolved before this is actionablehelp wantedIssue needs an assigneequestionUnresolved questions; type unclear

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions