mirror of
https://github.com/LeopoldArkham/humansize
synced 2024-11-10 06:14:15 +00:00
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:
parent
8b6903f3e3
commit
084d091e0e
3 changed files with 16 additions and 4 deletions
|
@ -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
|
||||||
|
|
|
@ -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 = []
|
||||||
|
|
|
@ -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]
|
||||||
|
|
Loading…
Reference in a new issue