Skip to content

Consider ZST values to be constant #1874

Closed
@torkleyy

Description

@torkleyy

If a value has a size of zero, there is nothing to allocate and it has no state so it should be constant and this should work:

struct Foo;

fn foo() -> &'static Foo {
    &Foo
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions