Add support for Rust 1.56.1

#[derive(Default)] requires Rust 1.62.0, so we reimplement
Default trait manualy to support older Rust versions.
This commit is contained in:
link2xt 2022-10-15 13:41:54 +00:00
parent 8b6903f3e3
commit 084d091e0e
3 changed files with 16 additions and 4 deletions

View file

@ -3,6 +3,7 @@ rust:
- stable - stable
- beta - beta
- nightly - nightly
- 1.56.1
sudo: false sudo: false
before_script: before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH

View file

@ -12,6 +12,7 @@ keywords = ["size", "formatting", "humanize", "file-size"]
categories = ["value-formatting"] categories = ["value-formatting"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
exclude = ["/feature-tests"] exclude = ["/feature-tests"]
rust-version = "1.56"
[features] [features]
no_alloc = [] no_alloc = []

View file

@ -4,16 +4,21 @@
mod defaults; mod defaults;
pub use self::defaults::*; pub use self::defaults::*;
#[derive(Debug, PartialEq, Eq, Copy, Clone, Default)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
/// Holds the standard to use when displaying the size. /// Holds the standard to use when displaying the size.
pub enum Kilo { pub enum Kilo {
/// The decimal scale and units. SI standard. /// The decimal scale and units. SI standard.
#[default]
Decimal, Decimal,
/// The binary scale and units. /// The binary scale and units.
Binary, Binary,
} }
impl Default for Kilo {
fn default() -> Self {
Self::Decimal
}
}
impl Kilo { impl Kilo {
pub(crate) fn value(&self) -> f64 { pub(crate) fn value(&self) -> f64 {
match self { match self {
@ -37,13 +42,18 @@ pub enum FixedAt {
Yotta, Yotta,
} }
#[derive(Debug, Copy, Clone, PartialEq, Default)] #[derive(Debug, Copy, Clone, PartialEq)]
pub enum BaseUnit { pub enum BaseUnit {
Bit, Bit,
#[default]
Byte, Byte,
} }
impl Default for BaseUnit {
fn default() -> Self {
Self::Byte
}
}
/// Holds the options for the `file_size` method. /// Holds the options for the `file_size` method.
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
#[non_exhaustive] #[non_exhaustive]