Skip to content

Commit

Permalink
inline a few trivial Wdl and Dtz methods
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Dec 30, 2024
1 parent 0665e7b commit 49abfee
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ impl Wdl {
}
}

#[inline]
pub(crate) fn decisive(self) -> Option<DecisiveWdl> {
Some(match self {
Wdl::Loss => DecisiveWdl::Loss,
Expand All @@ -292,6 +293,7 @@ impl Wdl {
/// * `1` if `self > Wdl::Draw`
/// * `0` if `self == Wdl::Draw`
/// * `-1` if `self < Wdl::Draw`
#[inline]
pub fn signum(self) -> i32 {
i32::from(self).signum()
}
Expand All @@ -300,6 +302,7 @@ impl Wdl {
impl Neg for Wdl {
type Output = Wdl;

#[inline]
fn neg(self) -> Wdl {
match self {
Wdl::Loss => Wdl::Win,
Expand Down Expand Up @@ -351,6 +354,7 @@ pub enum DecisiveWdl {
}

impl DecisiveWdl {
#[inline]
pub fn signum(self) -> i32 {
i32::from(self).signum()
}
Expand All @@ -359,6 +363,7 @@ impl DecisiveWdl {
impl Neg for DecisiveWdl {
type Output = DecisiveWdl;

#[inline]
fn neg(self) -> DecisiveWdl {
match self {
DecisiveWdl::Loss => DecisiveWdl::Win,
Expand Down Expand Up @@ -571,21 +576,25 @@ impl Dtz {
/// * `1` if `self > Dtz(0)`
/// * `0` if `self == Dtz(0)`
/// * `-1` if `self < Dtz(0)`
#[inline]
pub fn signum(self) -> i32 {
self.0.signum()
}

/// Returns `self == Dtz(0)`.
#[inline]
pub fn is_zero(self) -> bool {
self.0 == 0
}

/// Returns `self > Dtz(0)`.
#[inline]
pub fn is_positive(self) -> bool {
self.0 > 0
}

/// Returns `self < Dtz(0)`.
#[inline]
pub fn is_negative(self) -> bool {
self.0 < 0
}
Expand Down

0 comments on commit 49abfee

Please sign in to comment.