From d0d10bd0bbd65da01a9a50baa7efd41e9e54dd28 Mon Sep 17 00:00:00 2001 From: Tiaan Louw Date: Thu, 31 Aug 2023 14:12:34 +0200 Subject: [PATCH] Make NumberOrPercentage and AngleOrNumber getters public. Because the structs are public it only make sense to make the getters public as well. --- src/color.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/color.rs b/src/color.rs index 6c6ae8e1..477c40eb 100644 --- a/src/color.rs +++ b/src/color.rs @@ -669,14 +669,17 @@ pub enum NumberOrPercentage { } impl NumberOrPercentage { - fn unit_value(&self) -> f32 { + /// Return the value as a percentage. + pub fn unit_value(&self) -> f32 { match *self { NumberOrPercentage::Number { value } => value, NumberOrPercentage::Percentage { unit_value } => unit_value, } } - fn value(&self, percentage_basis: f32) -> f32 { + /// Return the value as a number with a percentage adjusted to the + /// `percentage_basis`. + pub fn value(&self, percentage_basis: f32) -> f32 { match *self { Self::Number { value } => value, Self::Percentage { unit_value } => unit_value * percentage_basis, @@ -699,7 +702,9 @@ pub enum AngleOrNumber { } impl AngleOrNumber { - fn degrees(&self) -> f32 { + /// Return the angle in degrees. `AngleOrNumber::Number` is returned as + /// degrees, because it is the canonical unit. + pub fn degrees(&self) -> f32 { match *self { AngleOrNumber::Number { value } => value, AngleOrNumber::Angle { degrees } => degrees,