Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Awpteamoose committed Oct 10, 2024
1 parent e96444f commit 4f21757
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 23 deletions.
7 changes: 6 additions & 1 deletion src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ use crate::{Datelike, Months, TimeDelta, Timelike, Weekday};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

/// documented at re-export site
Expand Down
7 changes: 6 additions & 1 deletion src/month.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ use core::fmt;
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

use crate::OutOfRange;
Expand Down
7 changes: 6 additions & 1 deletion src/naive/date/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ use core::{fmt, str};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

/// L10n locales.
Expand Down
7 changes: 6 additions & 1 deletion src/naive/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ use core::{fmt, str};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

#[cfg(feature = "alloc")]
Expand Down
14 changes: 10 additions & 4 deletions src/naive/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,16 @@ fn test_rkyv_validation() {
#[cfg(feature = "rkyv-08-bytecheck")]
fn test_rkyv_validation() {
let dt_min = NaiveDateTime::MIN;
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&dt_min).unwrap();
assert_eq!(rkyv_08::from_bytes::<NaiveDateTime, rkyv_08::rancor::Error>(&bytes).unwrap(), dt_min);
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&dt_min).unwrap();
assert_eq!(
rkyv_08::from_bytes::<NaiveDateTime, rkyv_08::rancor::Error>(&bytes).unwrap(),
dt_min
);

let dt_max = NaiveDateTime::MAX;
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&dt_max).unwrap();
assert_eq!(rkyv_08::from_bytes::<NaiveDateTime, rkyv_08::rancor::Error>(&bytes).unwrap(), dt_max);
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&dt_max).unwrap();
assert_eq!(
rkyv_08::from_bytes::<NaiveDateTime, rkyv_08::rancor::Error>(&bytes).unwrap(),
dt_max
);
}
17 changes: 14 additions & 3 deletions src/naive/isoweek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ use super::internals::YearFlags;
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

/// ISO 8601 week.
Expand Down Expand Up @@ -248,10 +253,16 @@ mod tests {
fn test_rkyv_bytecheck() {
let minweek = NaiveDate::MIN.iso_week();
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&minweek).unwrap();
assert_eq!(rkyv_08::from_bytes::<IsoWeek, rkyv_08::rancor::Error>(&bytes).unwrap(), minweek);
assert_eq!(
rkyv_08::from_bytes::<IsoWeek, rkyv_08::rancor::Error>(&bytes).unwrap(),
minweek
);

let maxweek = NaiveDate::MAX.iso_week();
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&maxweek).unwrap();
assert_eq!(rkyv_08::from_bytes::<IsoWeek, rkyv_08::rancor::Error>(&bytes).unwrap(), maxweek);
assert_eq!(
rkyv_08::from_bytes::<IsoWeek, rkyv_08::rancor::Error>(&bytes).unwrap(),
maxweek
);
}
}
7 changes: 6 additions & 1 deletion src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ use core::{fmt, str};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

#[cfg(feature = "alloc")]
Expand Down
14 changes: 11 additions & 3 deletions src/offset/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ use core::str::FromStr;
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

use super::{MappedLocalTime, Offset, TimeZone};
Expand Down Expand Up @@ -250,7 +255,10 @@ mod tests {
#[cfg(feature = "rkyv-08-bytecheck")]
fn test_rkyv_bytecheck() {
let offset = FixedOffset::from_str("-0500").unwrap();
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&offset).unwrap();
assert_eq!(rkyv_08::from_bytes::<FixedOffset, rkyv_08::rancor::Error>(&bytes).unwrap(), offset);
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&offset).unwrap();
assert_eq!(
rkyv_08::from_bytes::<FixedOffset, rkyv_08::rancor::Error>(&bytes).unwrap(),
offset
);
}
}
14 changes: 11 additions & 3 deletions src/offset/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ use std::cmp::Ordering;
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

use super::fixed::FixedOffset;
Expand Down Expand Up @@ -556,11 +561,14 @@ mod tests {
fn test_rkyv_bytecheck() {
let local = Local;
// Local is a ZST and serializes to 0 bytes
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&local).unwrap();
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&local).unwrap();
assert_eq!(bytes.len(), 0);

// but is deserialized to an archived variant without a
// wrapping object
assert_eq!(rkyv_08::from_bytes::<Local, rkyv_08::rancor::Error>(&bytes).unwrap(), super::ArchivedLocal);
assert_eq!(
rkyv_08::from_bytes::<Local, rkyv_08::rancor::Error>(&bytes).unwrap(),
super::ArchivedLocal
);
}
}
7 changes: 6 additions & 1 deletion src/offset/utc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ use std::time::{SystemTime, UNIX_EPOCH};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

use super::{FixedOffset, MappedLocalTime, Offset, TimeZone};
Expand Down
14 changes: 11 additions & 3 deletions src/time_delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ use crate::{expect, try_opt};
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

/// The number of nanoseconds in a microsecond.
Expand Down Expand Up @@ -1363,7 +1368,10 @@ mod tests {
#[cfg(feature = "rkyv-08-bytecheck")]
fn test_rkyv_bytecheck() {
let duration = TimeDelta::try_seconds(1).unwrap();
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&duration).unwrap();
assert_eq!(rkyv_08::from_bytes::<TimeDelta, rkyv_08::rancor::Error>(&bytes).unwrap(), duration);
let bytes = rkyv_08::to_bytes::<rkyv_08::rancor::Error>(&duration).unwrap();
assert_eq!(
rkyv_08::from_bytes::<TimeDelta, rkyv_08::rancor::Error>(&bytes).unwrap(),
duration
);
}
}
7 changes: 6 additions & 1 deletion src/weekday.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ use core::fmt;
#[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
use rkyv::{Archive, Deserialize, Serialize};

#[cfg(any(feature = "rkyv-08", feature = "rkyv-08-16", feature = "rkyv-08-32", feature = "rkyv-08-64"))]
#[cfg(any(
feature = "rkyv-08",
feature = "rkyv-08-16",
feature = "rkyv-08-32",
feature = "rkyv-08-64"
))]
use rkyv_08::{Archive, Deserialize, Serialize};

use crate::OutOfRange;
Expand Down

0 comments on commit 4f21757

Please sign in to comment.