Clippy: use from functions rather than as casts.
`as` is a many-faceted conversion operator, while `from` functions only do lossless conversions.
This commit is contained in:
@@ -197,7 +197,7 @@ pub(crate) fn poll_oneoff(
|
|||||||
nevents,
|
nevents,
|
||||||
);
|
);
|
||||||
|
|
||||||
if nsubscriptions as u64 > wasm32::__wasi_filesize_t::max_value() {
|
if u64::from(nsubscriptions) > wasm32::__wasi_filesize_t::max_value() {
|
||||||
return Err(Error::EINVAL);
|
return Err(Error::EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,13 +148,13 @@ fn wasi_clock_to_relative_ns_delay(
|
|||||||
wasi_clock: host::__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
|
wasi_clock: host::__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
|
||||||
) -> Result<u128> {
|
) -> Result<u128> {
|
||||||
if wasi_clock.flags != wasm32::__WASI_SUBSCRIPTION_CLOCK_ABSTIME {
|
if wasi_clock.flags != wasm32::__WASI_SUBSCRIPTION_CLOCK_ABSTIME {
|
||||||
return Ok(wasi_clock.timeout as u128);
|
return Ok(u128::from(wasi_clock.timeout));
|
||||||
}
|
}
|
||||||
let now: u128 = SystemTime::now()
|
let now: u128 = SystemTime::now()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
.map_err(|_| Error::ENOTCAPABLE)?
|
.map_err(|_| Error::ENOTCAPABLE)?
|
||||||
.as_nanos();
|
.as_nanos();
|
||||||
let deadline = wasi_clock.timeout as u128;
|
let deadline = u128::from(wasi_clock.timeout);
|
||||||
Ok(deadline.saturating_sub(now))
|
Ok(deadline.saturating_sub(now))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user