Skip to content

Commit f3e56c5

Browse files
committed
Arbitrary does not (yet) support no_std
1 parent 76822ae commit f3e56c5

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

src/date.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ where
555555

556556
// Note that implementation of Arbitrary cannot be automatically derived for Date<Tz>, due to
557557
// the nontrivial bound <Tz as TimeZone>::Offset: Arbitrary.
558-
#[cfg(feature = "arbitrary")]
558+
#[cfg(all(feature = "arbitrary", feature = "std"))]
559559
impl<'a, Tz> arbitrary::Arbitrary<'a> for Date<Tz>
560560
where
561561
Tz: TimeZone,

src/datetime/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ impl From<DateTime<Utc>> for js_sys::Date {
16961696

16971697
// Note that implementation of Arbitrary cannot be simply derived for DateTime<Tz>, due to
16981698
// the nontrivial bound <Tz as TimeZone>::Offset: Arbitrary.
1699-
#[cfg(feature = "arbitrary")]
1699+
#[cfg(all(feature = "arbitrary", feature = "std"))]
17001700
impl<'a, Tz> arbitrary::Arbitrary<'a> for DateTime<Tz>
17011701
where
17021702
Tz: TimeZone,

src/duration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ const fn div_mod_floor_64(this: i64, other: i64) -> (i64, i64) {
506506
(this.div_euclid(other), this.rem_euclid(other))
507507
}
508508

509-
#[cfg(feature = "arbitrary")]
509+
#[cfg(all(feature = "arbitrary", feature = "std"))]
510510
impl arbitrary::Arbitrary<'_> for Duration {
511511
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<Duration> {
512512
const MIN_SECS: i64 = -i64::MAX / MILLIS_PER_SEC - 1;

src/month.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::OutOfRange;
3737
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
3838
)]
3939
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
40-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
40+
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]
4141
pub enum Month {
4242
/// January
4343
January = 0,
@@ -225,7 +225,7 @@ impl num_traits::FromPrimitive for Month {
225225

226226
/// A duration in calendar months
227227
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
228-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
228+
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]
229229
pub struct Months(pub(crate) u32);
230230

231231
impl Months {

src/naive/date.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub const MIN_DATE: NaiveDate = NaiveDate::MIN;
207207
#[deprecated(since = "0.4.20", note = "Use NaiveDate::MAX instead")]
208208
pub const MAX_DATE: NaiveDate = NaiveDate::MAX;
209209

210-
#[cfg(feature = "arbitrary")]
210+
#[cfg(all(feature = "arbitrary", feature = "std"))]
211211
impl arbitrary::Arbitrary<'_> for NaiveDate {
212212
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<NaiveDate> {
213213
let year = u.int_in_range(MIN_YEAR..=MAX_YEAR)?;

src/naive/datetime/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub const MAX_DATETIME: NaiveDateTime = NaiveDateTime::MAX;
8181
archive_attr(derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash))
8282
)]
8383
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
84-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
84+
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]
8585
pub struct NaiveDateTime {
8686
date: NaiveDate,
8787
time: NaiveTime,

src/offset/fixed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl fmt::Display for FixedOffset {
176176
}
177177
}
178178

179-
#[cfg(feature = "arbitrary")]
179+
#[cfg(all(feature = "arbitrary", feature = "std"))]
180180
impl arbitrary::Arbitrary<'_> for FixedOffset {
181181
fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<FixedOffset> {
182182
let secs = u.int_in_range(-86_399..=86_399)?;

src/offset/utc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use crate::{Date, DateTime};
4848
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
4949
)]
5050
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
51-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
51+
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]
5252
pub struct Utc;
5353

5454
#[cfg(feature = "now")]

src/weekday.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::OutOfRange;
3838
archive_attr(derive(Clone, Copy, PartialEq, Eq, Debug, Hash))
3939
)]
4040
#[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
41-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
41+
#[cfg_attr(all(feature = "arbitrary", feature = "std"), derive(arbitrary::Arbitrary))]
4242
pub enum Weekday {
4343
/// Monday.
4444
Mon = 0,

0 commit comments

Comments
 (0)