[go: nahoru, domu]

Skip to content

Commit

Permalink
fix(lint): resolve clippy issues
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <git@mattglei.ch>
  • Loading branch information
gleich committed Jan 22, 2022
1 parent 484b888 commit 95643df
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
T: Integer + Display,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{}", self.0.to_string(), self.suffix())
write!(f, "{}{}", self.0, self.suffix())
}
}

Expand All @@ -43,23 +43,19 @@ where
/// # Examples
///
/// ```
/// use ordinal::Ordinal;
///
/// fn main() {
/// assert_eq!("nd", Ordinal(2).suffix());
/// }
/// assert_eq!("nd", Ordinal(2).suffix());
/// ```
pub fn suffix(&self) -> &str {
let s = self.0.to_string();
let suffix = if s.ends_with('1') && !s.ends_with("11") {
if s.ends_with('1') && !s.ends_with("11") {
"st"
} else if s.ends_with("2") && !s.ends_with("12") {
} else if s.ends_with('2') && !s.ends_with("12") {
"nd"
} else if s.ends_with("3") && !s.ends_with("13") {
} else if s.ends_with('3') && !s.ends_with("13") {
"rd"
} else {
"th"
};
suffix
}
}
}

Expand Down

0 comments on commit 95643df

Please sign in to comment.