Skip to content

Allow more const fns in std #1835

@F001

Description

@F001

Functions in std which could be evaluated in compile time should be qualified by const.

Such as:

fn size_of<T>() -> usize;
fn size_of_val<T: ?sized>(_: &T) -> usize;
fn type_name<T: ?sized>() -> &'static str;
fn type_id<T: ?Sized + 'static> () -> u64;
fn needs_drop<T>() -> bool;
......

I suppose they should be const fn. And there are more. Is it correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API 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