mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
clippy all codes (#1214)
1. clippy code 2. add fmt and clippy check in ci
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user