Fix clippy lints (#399)
* cargo fmt * fix: remove redundant `use libc` import (clippy::single_component_path_imports) * fix: use `.first()` instead of `.get(0)` (clippy::get_first) * fix: use `.copied()` instead of `.map(|s| *s)` (clippy::map_clone) * fix: allow too_many_arguments on ensure_daemon (clippy::too_many_arguments) * fix: use `then_some` instead of `then` with closure (clippy::unnecessary_lazy_evaluations) * fix: use pattern match instead of redundant guard (clippy::redundant_guards) * fix: use pattern match instead of redundant guard in commands.rs (clippy::redundant_guards) * fix: use `contains()` instead of `iter().any()` for simple equality (clippy::manual_contains) * Add changeset
This commit is contained in:
+22
-5
@@ -88,17 +88,28 @@ pub fn print_response(resp: &Response, json_mode: bool, action: Option<&str>) {
|
||||
// Separate real devices from simulators
|
||||
let real_devices: Vec<_> = devices
|
||||
.iter()
|
||||
.filter(|d| d.get("isRealDevice").and_then(|v| v.as_bool()).unwrap_or(false))
|
||||
.filter(|d| {
|
||||
d.get("isRealDevice")
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.collect();
|
||||
let simulators: Vec<_> = devices
|
||||
.iter()
|
||||
.filter(|d| !d.get("isRealDevice").and_then(|v| v.as_bool()).unwrap_or(false))
|
||||
.filter(|d| {
|
||||
!d.get("isRealDevice")
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if !real_devices.is_empty() {
|
||||
println!("Connected Devices:\n");
|
||||
for device in real_devices.iter() {
|
||||
let name = device.get("name").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let name = device
|
||||
.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown");
|
||||
let runtime = device.get("runtime").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let udid = device.get("udid").and_then(|v| v.as_str()).unwrap_or("");
|
||||
println!(" {} {} ({})", color::green("●"), name, runtime);
|
||||
@@ -110,9 +121,15 @@ pub fn print_response(resp: &Response, json_mode: bool, action: Option<&str>) {
|
||||
if !simulators.is_empty() {
|
||||
println!("Simulators:\n");
|
||||
for device in simulators.iter() {
|
||||
let name = device.get("name").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let name = device
|
||||
.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown");
|
||||
let runtime = device.get("runtime").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let state = device.get("state").and_then(|v| v.as_str()).unwrap_or("Unknown");
|
||||
let state = device
|
||||
.get("state")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown");
|
||||
let udid = device.get("udid").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let state_indicator = if state == "Booted" {
|
||||
color::green("●")
|
||||
|
||||
Reference in New Issue
Block a user