mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
test_infra: Implement fmt::Display for VerbosityLevel
warning: direct implementation of `ToString` --> test_infra/src/lib.rs:1214:1 | 1214 | / impl ToString for VerbosityLevel { 1215 | | fn to_string(&self) -> String { 1216 | | use VerbosityLevel::*; 1217 | | match self { ... | 1222 | | } 1223 | | } | |_^ | = help: prefer implementing `Display` instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl = note: `#[warn(clippy::to_string_trait_impl)]` on by default Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
parent
1e3d21e504
commit
ab9fc3a8a0
@ -10,6 +10,7 @@ use serde_json::Value;
|
|||||||
use ssh2::Session;
|
use ssh2::Session;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::fmt::Display;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
@ -1211,14 +1212,15 @@ impl Default for VerbosityLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for VerbosityLevel {
|
impl Display for VerbosityLevel {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
use VerbosityLevel::*;
|
use VerbosityLevel::*;
|
||||||
match self {
|
match self {
|
||||||
Warn => "".to_string(),
|
Warn => (),
|
||||||
Info => "-v".to_string(),
|
Info => write!(f, "-v")?,
|
||||||
Debug => "-vv".to_string(),
|
Debug => write!(f, "-vv")?,
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user