Skip to content

Commit 5932443

Browse files
committed
clippy cleanup
1 parent 0cd893e commit 5932443

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/implementation.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ pub mod lambda_private {
505505
status_ok: bool, // HTTP status was 2xx
506506
}
507507

508-
impl ProbeResult {
508+
impl std::fmt::Display for ProbeResult {
509509
/// Format probe result as 8-character bitmap matching Varnish format:
510510
/// Position 0: '4' if invoked successfully, '-' if failed
511511
/// Position 1: '-' (no IPv6)
@@ -515,17 +515,15 @@ pub mod lambda_private {
515515
/// Position 5: 'r' if payload problem, '-' if ok
516516
/// Position 6: 'R' if payload valid, '-' if not
517517
/// Position 7: 'H' if happy (2xx status), '-' if not
518-
fn to_string(&self) -> String {
519-
let mut s = String::with_capacity(8);
520-
s.push(if self.invoked { '4' } else { '-' });
521-
s.push('-'); // No IPv6
522-
s.push('-'); // No Unix sockets
523-
s.push(if self.invoked { '-' } else { 'x' });
524-
s.push(if self.invoked { 'X' } else { '-' });
525-
s.push(if !self.invoked || self.received { '-' } else { 'r' });
526-
s.push(if self.received { 'R' } else { '-' });
527-
s.push(if self.status_ok { 'H' } else { '-' });
528-
s
518+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
519+
write!(f, "{}--{}{}{}{}{}",
520+
if self.invoked { '4' } else { '-' },
521+
if self.invoked { '-' } else { 'x' },
522+
if self.invoked { 'X' } else { '-' },
523+
if !self.invoked || self.received { '-' } else { 'r' },
524+
if self.received { 'R' } else { '-' },
525+
if self.status_ok { 'H' } else { '-' }
526+
)
529527
}
530528
}
531529

@@ -604,7 +602,7 @@ pub mod lambda_private {
604602
name,
605603
if health_update.health_unchanged { "Still" } else { "Went" },
606604
if health_update.is_healthy { "healthy" } else { "sick" },
607-
probe_result.to_string(),
605+
probe_result,
608606
good_probes(health_update.bitmap, spec.window),
609607
spec.threshold,
610608
spec.window,

0 commit comments

Comments
 (0)