gpui: Make length helpers into const functions (#44259)

Make gpui's `rems()`, `phi()`, `auto()` length related helpers into
const functions.

I can't see why these functions aren't already const except that it
must've been overlooked when they were written?

In my project I had need for rems() to be const, and I thought I'd do
phi() and auto() whilst I was in the neighbourhood

Release Notes:

- N/A
This commit is contained in:
Serophots
2025-12-06 01:08:43 +00:00
committed by GitHub
parent 4cef8eb47b
commit 9860884217
+3 -3
View File
@@ -3567,7 +3567,7 @@ pub const fn relative(fraction: f32) -> DefiniteLength {
}
/// Returns the Golden Ratio, i.e. `~(1.0 + sqrt(5.0)) / 2.0`.
pub fn phi() -> DefiniteLength {
pub const fn phi() -> DefiniteLength {
relative(1.618_034)
}
@@ -3580,7 +3580,7 @@ pub fn phi() -> DefiniteLength {
/// # Returns
///
/// A `Rems` representing the specified number of rems.
pub fn rems(rems: f32) -> Rems {
pub const fn rems(rems: f32) -> Rems {
Rems(rems)
}
@@ -3608,7 +3608,7 @@ pub const fn px(pixels: f32) -> Pixels {
/// # Returns
///
/// A `Length` variant set to `Auto`.
pub fn auto() -> Length {
pub const fn auto() -> Length {
Length::Auto
}