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
- beta
- nightly
- 1.56.1
sudo: false
before_script:
- 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"]
license = "MIT/Apache-2.0"
exclude = ["/feature-tests"]
rust-version = "1.56"
[features]
no_alloc = []

View file

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