From 0c3fb449f044d550b871abfa3f568343ddf38cc5 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Mon, 22 Jan 2024 08:11:21 -0800 Subject: [PATCH] Document geometry --- crates/gpui/src/geometry.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs index ef71f94ef6..dd826b68f5 100644 --- a/crates/gpui/src/geometry.rs +++ b/crates/gpui/src/geometry.rs @@ -31,11 +31,15 @@ impl Axis { } } +/// A trait for accessing the given unit along a certain axis. pub trait Along { + /// The unit associated with this type type Unit; + /// Returns the unit along the given axis. fn along(&self, axis: Axis) -> Self::Unit; + /// Applies the given function to the unit along the given axis and returns a new value. fn apply_along(&self, axis: Axis, f: impl FnOnce(Self::Unit) -> Self::Unit) -> Self; } @@ -55,7 +59,9 @@ pub trait Along { #[refineable(Debug)] #[repr(C)] pub struct Point { + /// The x coordinate of the point. pub x: T, + /// The y coordinate of the point. pub y: T, } @@ -342,7 +348,9 @@ impl Clone for Point { #[refineable(Debug)] #[repr(C)] pub struct Size { + /// The width component of the size. pub width: T, + /// The height component of the size. pub height: T, } @@ -648,7 +656,9 @@ impl Size { #[refineable(Debug)] #[repr(C)] pub struct Bounds { + /// The origin point of this area. pub origin: Point, + /// The size of the rectangle. pub size: Size, } @@ -1200,9 +1210,13 @@ impl Copy for Bounds {} #[refineable(Debug)] #[repr(C)] pub struct Edges { + /// The size of the top edge. pub top: T, + /// The size of the right edge. pub right: T, + /// The size of the bottom edge. pub bottom: T, + /// The size of the left edge. pub left: T, } @@ -1608,9 +1622,13 @@ impl From for Edges { #[refineable(Debug)] #[repr(C)] pub struct Corners { + /// The value associated with the top left corner. pub top_left: T, + /// The value associated with the top right corner. pub top_right: T, + /// The value associated with the bottom right corner. pub bottom_right: T, + /// The value associated with the bottom left corner. pub bottom_left: T, }