Skip to content

Commit

Permalink
style(Backend): 🎨 auto clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Jul 23, 2024
1 parent 7dd380b commit 6846505
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 110 deletions.
98 changes: 0 additions & 98 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"frontend",
"backend",
"judger",
"testsuit",
# "testsuit",
"backend/migration",
"grpc",
"judger/plugins/rlua-54",
Expand Down
7 changes: 3 additions & 4 deletions backend/src/endpoint/contest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ impl Contest for ArcServer {
} else {
return Err(Error::PermissionDeny(
"mismatch password(root can update password without entering original password)",
)
.into());
));
}
}
}
Expand Down Expand Up @@ -284,8 +283,8 @@ impl Contest for ArcServer {
.password
.as_ref()
.ok_or(Error::NotInPayload("password"))?;
if !self.crypto.hash_eq(&password, &tar) {
return Err(Error::PermissionDeny("mismatched password").into());
if !self.crypto.hash_eq(password, &tar) {
return Err(Error::PermissionDeny("mismatched password"));
}
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/endpoint/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl Problem for ArcServer {
.map_err(Into::<Error>::into)?;

if result.rows_affected == 0 {
return Err(Error::NotInDB.into());
return Err(Error::NotInDB);
}
Ok(())
})
Expand Down
8 changes: 4 additions & 4 deletions backend/src/endpoint/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl User for ArcServer {
{
perm.admin()?;
if new_perm > perm {
return Err(Error::RequirePermission(new_perm).into());
return Err(Error::RequirePermission(new_perm));
}
}

Expand Down Expand Up @@ -174,11 +174,11 @@ impl User for ArcServer {
let new_perm: Role = new_perm.try_into().unwrap_or_default();
let new_perm: RoleLv = new_perm.into();
if perm < new_perm {
return Err(Error::RequirePermission(new_perm).into());
return Err(Error::RequirePermission(new_perm));
}
model.permission = ActiveValue::set(new_perm as i32);
if new_perm > perm {
return Err(Error::RequirePermission(new_perm).into());
return Err(Error::RequirePermission(new_perm));
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ impl User for ArcServer {
.ok_or(Error::NotInDB)?;

if !self.crypto.hash_eq(req.password.as_str(), &model.password) {
return Err(Error::PermissionDeny("wrong original password").into());
return Err(Error::PermissionDeny("wrong original password"));
}

let mut model = model.into_active_model();
Expand Down
4 changes: 2 additions & 2 deletions backend/src/util/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl_list_rate_limit!(Announcement);
impl RateLimit for ListUserRequest {
fn get_cost(&self) -> u32 {
self.size
.saturating_add(self.offset.abs() as u64 / 6)
.saturating_add(self.offset.unsigned_abs() / 6)
.saturating_add(12)
.min(u32::MAX as u64) as u32
}
Expand All @@ -134,7 +134,7 @@ impl RateLimit for ListUserRequest {
impl RateLimit for ListChatRequest {
fn get_cost(&self) -> u32 {
self.size
.saturating_add(self.offset.abs() as u64 / 8)
.saturating_add(self.offset.unsigned_abs() / 8)
.saturating_add(3)
.min(u32::MAX as u64) as u32
}
Expand Down

0 comments on commit 6846505

Please sign in to comment.