mirror of
https://github.com/LeopoldArkham/humansize
synced 2024-11-22 03:33:10 +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
|
||||
- beta
|
||||
- nightly
|
||||
- 1.56.1
|
||||
sudo: false
|
||||
before_script:
|
||||
- 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"]
|
||||
license = "MIT/Apache-2.0"
|
||||
exclude = ["/feature-tests"]
|
||||
rust-version = "1.56"
|
||||
|
||||
[features]
|
||||
no_alloc = []
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue