clippy all codes (#1214)

1. clippy code
2. add fmt and clippy check in ci
This commit is contained in:
Sijie.Sun
2025-08-10 22:56:41 +08:00
committed by GitHub
parent 0087ac3ffc
commit e43537939a
144 changed files with 1475 additions and 1531 deletions
+11 -4
View File
@@ -277,6 +277,12 @@ pub struct UnsafeCounter {
value: UnsafeCell<u64>,
}
impl Default for UnsafeCounter {
fn default() -> Self {
Self::new()
}
}
impl UnsafeCounter {
pub fn new() -> Self {
Self {
@@ -396,14 +402,15 @@ impl MetricKey {
fn new(name: MetricName, labels: LabelSet) -> Self {
Self { name, labels }
}
}
/// Generate a string representation for this metric key
fn to_string(&self) -> String {
impl fmt::Display for MetricKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let label_str = self.labels.to_key();
if label_str.is_empty() {
self.name.to_string()
f.write_str(self.name.to_string().as_str())
} else {
format!("{}[{}]", self.name, label_str)
f.write_str(format!("{}[{}]", self.name, label_str).as_str())
}
}
}