diff options
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. |