diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 18:05:33 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 18:05:33 +0200 |
commit | 2c7980b773cad586af5db8ff0755f1d74d94f7d1 (patch) | |
tree | 5207aa3a69945ae7d5e5ef77ad14a50313954c25 /crates/bytes/src/lib.rs | |
parent | feat(unreachable): Init trait (diff) | |
download | yt-2c7980b773cad586af5db8ff0755f1d74d94f7d1.tar.gz yt-2c7980b773cad586af5db8ff0755f1d74d94f7d1.zip |
refactor(treewide): Conform to the clippy and rust lints
Diffstat (limited to 'crates/bytes/src/lib.rs')
-rw-r--r-- | crates/bytes/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/bytes/src/lib.rs b/crates/bytes/src/lib.rs index 78d3c4e..6e3f73c 100644 --- a/crates/bytes/src/lib.rs +++ b/crates/bytes/src/lib.rs @@ -8,6 +8,12 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +#![allow( + clippy::cast_possible_truncation, + clippy::cast_precision_loss, + clippy::cast_sign_loss, + clippy::cast_possible_wrap +)] use std::{fmt::Display, str::FromStr}; use error::BytesError; @@ -28,13 +34,15 @@ const TB: u64 = 1000 * GB; pub mod error; pub mod serde; -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct Bytes(u64); impl Bytes { + #[must_use] pub fn as_u64(self) -> u64 { self.0 } + #[must_use] pub fn new(v: u64) -> Self { Self(v) } @@ -140,6 +148,7 @@ impl Display for Bytes { /// assert_eq!(precision_f64(1.2300_f32 as f64, 2) as f32, 1.2f32); ///# } /// ``` +#[must_use] pub fn precision_f64(x: f64, decimals: u32) -> f64 { if x == 0. || decimals == 0 { 0. |