chore: justify the remaining keep-only cast + serde-default allows with reasons
This commit is contained in:
parent
30be7cd632
commit
f9fe3280f9
3 changed files with 13 additions and 3 deletions
|
|
@ -168,7 +168,10 @@ struct BashRunArgs {
|
|||
wait_seconds: Option<u64>,
|
||||
}
|
||||
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
#[allow(
|
||||
clippy::unnecessary_wraps,
|
||||
reason = "serde `#[serde(default = ...)]` requires the default fn's return type to match the field's `Option<u64>`, so the `Some` wrap is mandatory even though the value is constant"
|
||||
)]
|
||||
fn default_wait() -> Option<u64> {
|
||||
Some(3)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,11 @@ fn now_secs() -> i64 {
|
|||
.map_or(0, |d| i64::try_from(d.as_secs()).unwrap_or(i64::MAX))
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||
#[allow(
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "v.max(0) clamps to a non-negative value first, so the i64->u64 cast is exact: no sign loss, and no truncation since u64 covers all non-negative i64"
|
||||
)]
|
||||
fn u64_from_i64(v: i64) -> u64 {
|
||||
v.max(0) as u64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,10 @@ fn fetch_head(client: &Client, repo: &str, number: u64, limit: u64) -> Result<Ve
|
|||
/// first to know how many exist, then start paginating from the
|
||||
/// page that contains item `total - n`. Work is bounded by
|
||||
/// `ceil(n/50) + 1` page fetches, regardless of thread length.
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[allow(
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "the forge `comments` count cast to usize is a small issue-thread length, never anywhere near usize::MAX even on a 32-bit target, so it cannot truncate in practice"
|
||||
)]
|
||||
fn fetch_tail(client: &Client, repo: &str, number: u64, n: usize) -> Result<Vec<Value>> {
|
||||
if n == 0 {
|
||||
return Ok(Vec::new());
|
||||
|
|
|
|||
Loading…
Reference in a new issue