fix:Apply suggestions from clippy 1.88

This commit is contained in:
houseme
2025-06-27 18:16:29 +08:00
parent 35489ea352
commit 749537664f
108 changed files with 642 additions and 682 deletions
+2 -2
View File
@@ -612,7 +612,7 @@ mod tests {
timeout: Duration::from_secs(5),
retry_interval: Duration::from_millis(100),
};
let debug_str = format!("{:?}", opts);
let debug_str = format!("{opts:?}");
assert!(debug_str.contains("timeout"));
assert!(debug_str.contains("retry_interval"));
}
@@ -850,7 +850,7 @@ mod tests {
let lockers = create_mock_lockers(1);
let mutex = DRWMutex::new("owner1".to_string(), names, lockers);
let debug_str = format!("{:?}", mutex);
let debug_str = format!("{mutex:?}");
assert!(debug_str.contains("DRWMutex"));
assert!(debug_str.contains("owner"));
assert!(debug_str.contains("names"));
+7 -9
View File
@@ -117,8 +117,7 @@ impl Locker for LocalLocker {
async fn lock(&mut self, args: &LockArgs) -> Result<bool> {
if args.resources.len() > MAX_DELETE_LIST {
return Err(Error::other(format!(
"internal error: LocalLocker.lock called with more than {} resources",
MAX_DELETE_LIST
"internal error: LocalLocker.lock called with more than {MAX_DELETE_LIST} resources"
)));
}
@@ -153,8 +152,7 @@ impl Locker for LocalLocker {
async fn unlock(&mut self, args: &LockArgs) -> Result<bool> {
if args.resources.len() > MAX_DELETE_LIST {
return Err(Error::other(format!(
"internal error: LocalLocker.unlock called with more than {} resources",
MAX_DELETE_LIST
"internal error: LocalLocker.unlock called with more than {MAX_DELETE_LIST} resources"
)));
}
@@ -165,9 +163,9 @@ impl Locker for LocalLocker {
Some(lris) => {
if !is_write_lock(lris) {
if err_info.is_empty() {
err_info = format!("unlock attempted on a read locked entity: {}", resource);
err_info = format!("unlock attempted on a read locked entity: {resource}");
} else {
err_info.push_str(&format!(", {}", resource));
err_info.push_str(&format!(", {resource}"));
}
} else {
lris.retain(|lri| {
@@ -249,7 +247,7 @@ impl Locker for LocalLocker {
match self.lock_map.get_mut(resource) {
Some(lris) => {
if is_write_lock(lris) {
return Err(Error::other(format!("runlock attempted on a write locked entity: {}", resource)));
return Err(Error::other(format!("runlock attempted on a write locked entity: {resource}")));
} else {
lris.retain(|lri| {
if lri.uid == args.uid && (args.owner.is_empty() || lri.owner == args.owner) {
@@ -405,10 +403,10 @@ mod test {
};
local_locker.lock(&args).await?;
println!("lock local_locker: {:?} \n", local_locker);
println!("lock local_locker: {local_locker:?} \n");
local_locker.unlock(&args).await?;
println!("unlock local_locker: {:?}", local_locker);
println!("unlock local_locker: {local_locker:?}");
Ok(())
}
+6 -6
View File
@@ -25,7 +25,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.lock(request).await.map_err(Error::other)?.into_inner();
@@ -42,7 +42,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.un_lock(request).await.map_err(Error::other)?.into_inner();
@@ -59,7 +59,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.r_lock(request).await.map_err(Error::other)?.into_inner();
@@ -76,7 +76,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.r_un_lock(request).await.map_err(Error::other)?.into_inner();
@@ -93,7 +93,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.refresh(request).await.map_err(Error::other)?.into_inner();
@@ -110,7 +110,7 @@ impl Locker for RemoteClient {
let args = serde_json::to_string(args)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GenerallyLockRequest { args });
let response = client.force_un_lock(request).await.map_err(Error::other)?.into_inner();