Skip to content

Commit

Permalink
reorder functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 18, 2024
1 parent e978b03 commit 0ddd370
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,21 @@ impl Version {
#[allow(clippy::inherent_to_string_shadow_display)] // ok because this to_string() is about 20% faster than the Display impl
pub fn to_string(&self) -> String {
capacity_builder::StringBuilder::build(|builder| {
build_to_string(self, builder);
build_version_to_string(self, builder);
})
.unwrap()
}
}

fn build_to_string<'a>(
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
capacity_builder::StringBuilder::fmt(f, |builder| {
build_version_to_string(self, builder);
})
}
}

fn build_version_to_string<'a>(
version: &'a Version,
builder: &mut capacity_builder::StringBuilder<'a, '_, '_>,
) {
Expand Down Expand Up @@ -125,14 +133,6 @@ fn build_to_string<'a>(
}
}

impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
capacity_builder::StringBuilder::fmt(f, |builder| {
build_to_string(self, builder);
})
}
}

impl std::cmp::PartialOrd for Version {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
Expand Down

0 comments on commit 0ddd370

Please sign in to comment.