Skip to content

Encoded metadata at compile time #223

Open
@nazar-pc

Description

@nazar-pc

I'd like to be able to use metadata generation during compilation type in const fn environment. The result will be stored in const or static and avoiding build scripts and boilerplate would be very desirable.

Something like this:

const fn foo() {
    let mut buffer = [0u8; MAX_METADATA_CAPACITY];
    let metadata_size = MyType::type_info_encode_into(&mut buffer).unwrap();
    let encoded_metadata = &encoded[..metadata_size];
    // ...
}

Traits with const fn methods are very much unstable, but derive macro could have generated a regular impl with a method in it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions