From 98608842175f02f503581737f9eb69eea01b56df Mon Sep 17 00:00:00 2001 From: Serophots <47299955+Serophots@users.noreply.github.com> Date: Sat, 6 Dec 2025 01:08:43 +0000 Subject: [PATCH] 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 --- crates/gpui/src/geometry.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index 859ecb3d0e6c7b5c33f5765ce4c6295cef7fd566..4daec6d15367f3e12bab3cba658ccb3f261e9f46 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -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 }