Skip to content

More const functions #7557

@TH3-S4LM0N

Description

@TH3-S4LM0N

There are a lot of functions for building things that aren't declared as constant, even though they are constant.
The example that gets me the most is bevy_render::mesh::shape::Box::new isn't a const even though it's literally:

pub fn new(x_length: f32, y_length: f32, z_length: f32) -> Box {
        Box {
            max_x: x_length / 2.0,
            min_x: -x_length / 2.0,
            max_y: y_length / 2.0,
            min_y: -y_length / 2.0,
            max_z: z_length / 2.0,
            min_z: -z_length / 2.0,
        }
}

and really has no reason not to be const. This is just an example, but there are tons of functions that should be constant.

In the end this is just a suggestion, bevy is already huge so it might be unrealistic to go through it all again and figure out what can and can't be const, I'm just trying to bring attention to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions