Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro committed Mar 2, 2025
1 parent 9b23f8a commit 03ab567
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl FromStr for PublishPort {
fn from_str(src: &str) -> Result<Self, Self::Err> {
let parts: Vec<&str> = src.split(':').collect();

if parts[0] == "" {
if parts[0].is_empty() {
return Err("Expected format: [[hostip:][hostport]:]vmport".to_string());
}

Expand Down Expand Up @@ -93,7 +93,7 @@ impl FromStr for PublishPort {
let vm_port = parts[2]
.parse()
.map_err(|_| format!("'{}' is not a valid port", parts[2]))?;
let host_port = if parts[1] != "" {
let host_port = if !parts[1].is_empty() {
parts[1]
.parse()
.map_err(|_| format!("'{}' is not a valid port", parts[1]))?
Expand Down
18 changes: 13 additions & 5 deletions src/qemu.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Write;
use std::{
path::{Path, PathBuf},
process::Stdio,
Expand Down Expand Up @@ -192,11 +193,18 @@ pub async fn launch_qemu(
let sshd_dropin_base64 = Base64::encode_string(sshd_dropin.as_bytes());
let cid = qemu_launch_opts.cid;

let hostfwd: String = qemu_launch_opts
.published_ports
.iter()
.map(|p| format!(",hostfwd=:{}:{}-:{}", p.host_ip, p.host_port, p.vm_port))
.collect();
let hostfwd: String =
qemu_launch_opts
.published_ports
.iter()
.fold(String::new(), |mut output, p| {
let _ = write!(
output,
",hostfwd=:{}:{}-:{}",
p.host_ip, p.host_port, p.vm_port
);
output
});

let qmp_socket_path = run_dir.join("qmp.sock,server,wait=off");
let qmp_socket_path_str = qmp_socket_path.to_string_lossy();
Expand Down

0 comments on commit 03ab567

Please sign in to comment.