Adding in Percentage::as_option_end and Percentage::as_option_start

This commit is contained in:
Pauan 2018-06-08 06:00:33 -10:00
parent a751f76acf
commit 291273bcc0
1 changed files with 18 additions and 0 deletions

View File

@ -460,6 +460,24 @@ impl Percentage {
pub fn into_f64(self) -> f64 {
self.0
}
pub fn as_option_end(self) -> Option<Self> {
if self.0 == 1.0 {
None
} else {
Some(self)
}
}
pub fn as_option_start(self) -> Option<Self> {
if self.0 == 0.0 {
None
} else {
Some(self)
}
}
}
#[inline]