Skip to content

Commit

Permalink
Fixing clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelff committed Nov 29, 2023
1 parent 4667478 commit 22042e1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
16 changes: 2 additions & 14 deletions libs/crosstarget-utils/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use std::fmt::Display;

#[derive(Debug)]
pub struct SpawnError {}

impl SpawnError {
pub fn new() -> Self {
SpawnError {}
}
}
pub struct SpawnError;

impl Display for SpawnError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -18,13 +12,7 @@ impl Display for SpawnError {
impl std::error::Error for SpawnError {}

#[derive(Debug)]
pub struct TimeoutError {}

impl TimeoutError {
pub fn new() -> Self {
TimeoutError {}
}
}
pub struct TimeoutError;

impl Display for TimeoutError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion libs/crosstarget-utils/src/native/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ where
F: Future + 'static + Send,
F::Output: Send + 'static,
{
tokio::spawn(future).await.map_err(|_| SpawnError::new())
tokio::spawn(future).await.map_err(|_| SpawnError)
}
4 changes: 2 additions & 2 deletions libs/crosstarget-utils/src/native/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl ElapsedTimeCounter {
}
}

pub async fn sleep(duration: Duration) -> () {
pub async fn sleep(duration: Duration) {
tokio::time::sleep(duration).await
}

Expand All @@ -31,5 +31,5 @@ where
{
let result = tokio::time::timeout(duration, future).await;

result.map_err(|_| TimeoutError::new())
result.map_err(|_| TimeoutError)
}
2 changes: 1 addition & 1 deletion libs/crosstarget-utils/src/wasm/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
{
tokio::select! {
result = future => Ok(result),
_ = sleep(duration) => Err(TimeoutError::new())
_ = sleep(duration) => Err(TimeoutError)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Display for ExecutorProcessDiedError {

impl StdError for ExecutorProcessDiedError {}

pub(super) static EXTERNAL_PROCESS: Lazy<RestartableExecutorProcess> = Lazy::new(|| RestartableExecutorProcess::new());
pub(super) static EXTERNAL_PROCESS: Lazy<RestartableExecutorProcess> = Lazy::new(RestartableExecutorProcess::new);

type ReqImpl = (
jsonrpc_core::MethodCall,
Expand Down Expand Up @@ -215,7 +215,7 @@ fn start_rpc_thread(mut receiver: mpsc::Receiver<ReqImpl>) -> Result<()> {
{
tracing::error!("Error when reading from child node process. Process might have exited. Restarting...");
if let Some((_, sender)) = last_pending_request.take() {
let _ = sender.send(Err(Box::new(ExecutorProcessDiedError))).unwrap();
sender.send(Err(Box::new(ExecutorProcessDiedError))).unwrap();
}
EXTERNAL_PROCESS.restart().await;
break;
Expand Down

0 comments on commit 22042e1

Please sign in to comment.