Skip to content

Commit 9c53e4f

Browse files
authored
Make NumberOrPercentage and AngleOrNumber getters public. (servo#357)
Because the structs are public it only make sense to make the getters public as well.
1 parent d320a8e commit 9c53e4f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/color.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,17 @@ pub enum NumberOrPercentage {
669669
}
670670

671671
impl NumberOrPercentage {
672-
fn unit_value(&self) -> f32 {
672+
/// Return the value as a percentage.
673+
pub fn unit_value(&self) -> f32 {
673674
match *self {
674675
NumberOrPercentage::Number { value } => value,
675676
NumberOrPercentage::Percentage { unit_value } => unit_value,
676677
}
677678
}
678679

679-
fn value(&self, percentage_basis: f32) -> f32 {
680+
/// Return the value as a number with a percentage adjusted to the
681+
/// `percentage_basis`.
682+
pub fn value(&self, percentage_basis: f32) -> f32 {
680683
match *self {
681684
Self::Number { value } => value,
682685
Self::Percentage { unit_value } => unit_value * percentage_basis,
@@ -699,7 +702,9 @@ pub enum AngleOrNumber {
699702
}
700703

701704
impl AngleOrNumber {
702-
fn degrees(&self) -> f32 {
705+
/// Return the angle in degrees. `AngleOrNumber::Number` is returned as
706+
/// degrees, because it is the canonical unit.
707+
pub fn degrees(&self) -> f32 {
703708
match *self {
704709
AngleOrNumber::Number { value } => value,
705710
AngleOrNumber::Angle { degrees } => degrees,

0 commit comments

Comments
 (0)