Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit 899c186

Browse files
committed
cargo clippy fixes
1 parent e18f35f commit 899c186

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

src/app/api.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ impl Api {
512512
Err(err) => {
513513
error!("failed to read request: {}", err);
514514
let _ = stream.write_all("bad request".as_ref()).await;
515-
return;
516515
}
517516
}
518517
}
@@ -722,7 +721,7 @@ impl Client {
722721
let data = data.trim_end();
723722

724723
// Parse the JSON-RPC response
725-
let response: JsonRpcResponse = encoder::from_str(&data)?;
724+
let response: JsonRpcResponse = encoder::from_str(data)?;
726725

727726
// Handle the response
728727
if let Some(error) = response.error {
@@ -764,7 +763,7 @@ impl Client {
764763
let data = String::from_utf8(buffer)?;
765764
let data = data.trim_end();
766765

767-
let response: Response = encoder::from_str(&data)?;
766+
let response: Response = encoder::from_str(data)?;
768767

769768
match response.state {
770769
State::Ok => Ok(response.body),

src/manager/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ type Handler = oneshot::Sender<WaitStatus>;
4747

4848
impl Process {
4949
pub fn new<S: Into<String>>(cmd: S, cwd: S, env: Option<HashMap<String, String>>) -> Process {
50-
let env = match env {
51-
None => HashMap::new(),
52-
Some(env) => env,
53-
};
50+
let env = env.unwrap_or_default();
5451

5552
Process {
5653
env,

src/zinit/lifecycle.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl LifecycleManager {
9797
let service = Arc::new(RwLock::new(ZInitService::new(service, State::Unknown)));
9898
services.insert(name.clone(), Arc::clone(&service));
9999

100-
let lifecycle = self.clone();
100+
let lifecycle = self.clone_lifecycle();
101101
debug!("service '{}' monitored", name);
102102
tokio::spawn(lifecycle.watch_service(name, service));
103103

@@ -132,7 +132,7 @@ impl LifecycleManager {
132132
.get(name.as_ref())
133133
.ok_or_else(|| ZInitError::unknown_service(name.as_ref()))?;
134134

135-
let lifecycle = self.clone();
135+
let lifecycle = self.clone_lifecycle();
136136
tokio::spawn(lifecycle.watch_service(name.as_ref().into(), Arc::clone(service)));
137137

138138
Ok(())
@@ -284,7 +284,7 @@ impl LifecycleManager {
284284
}
285285

286286
let shutdown_timeout = shutdown_timeouts.remove(child);
287-
let lifecycle = self.clone();
287+
let lifecycle = self.clone_lifecycle();
288288
tokio::spawn(Self::kill_wait(
289289
lifecycle,
290290
child.to_string(),
@@ -551,7 +551,7 @@ impl LifecycleManager {
551551

552552
let mut handler = None;
553553
if !config.one_shot {
554-
let lifecycle = self.clone();
554+
let lifecycle = self.clone_lifecycle();
555555
handler = Some(tokio::spawn(
556556
lifecycle.test_loop(name.clone(), config.clone()),
557557
));
@@ -595,7 +595,7 @@ impl LifecycleManager {
595595
}
596596

597597
/// Clone the lifecycle manager
598-
pub fn clone(&self) -> Self {
598+
pub fn clone_lifecycle(&self) -> Self {
599599
Self {
600600
pm: self.pm.clone(),
601601
services: Arc::clone(&self.services),

src/zinit/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ZInit {
4040
pub fn serve(&self) {
4141
self.lifecycle.process_manager().start();
4242
if self.lifecycle.is_container_mode() {
43-
let lifecycle = self.lifecycle.clone();
43+
let lifecycle = self.lifecycle.clone_lifecycle();
4444
tokio::spawn(async move {
4545
use tokio::signal::unix;
4646

src/zinit/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub async fn service_dependency_order(services: Arc<RwLock<ServiceTable>>) -> Pr
1818
for child in service.service.after.iter() {
1919
children
2020
.entry(name.into())
21-
.or_insert_with(Vec::new)
21+
.or_default()
2222
.push(child.into());
2323
*indegree.entry(child.into()).or_insert(0) += 1;
2424
}

0 commit comments

Comments
 (0)