Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Serophots98608842175f
diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs
index 859ecb3d0e6..4daec6d1536 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
}