Skip to content

Commit cf3a562

Browse files
committed
fix: fixing msrv ci test by making the library use std for components that don't exist on older versions of rust core
1 parent 6a38ae6 commit cf3a562

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ include = ["Cargo.toml", "CHANGELOG.md", "LICENSE-MIT", "LICENSE-APACHE", "READM
2222

2323
[dependencies]
2424
derive_arbitrary = { version = "~1.4.0", path = "./derive", optional = true }
25+
rustversion = "1"
2526

2627
[features]
2728
default = ["std"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ compile with older versions but that may change in any new patch release.
130130
We reserve the right to increment the MSRV on minor releases, however we will
131131
strive to only do it deliberately and for good reasons.
132132

133+
### Notes on no_std compatability:
134+
135+
- When compiling for versions older than **1.81.0** the `std` feature must be enabled.
136+
- When compiling for versions older than **1.64.0** the `impl` for `CString` is not available
137+
with the `no_std` feature. And
138+
133139
## License
134140

135141
Licensed under dual MIT or Apache-2.0 at your choice.

src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
use core::{error, fmt};
1+
use core::fmt;
2+
3+
#[rustversion::before(1.81)]
4+
use std::error;
5+
6+
#[rustversion::since(1.81)]
7+
use core::error;
28

39
/// An enumeration of buffer creation errors
410
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

src/foreign/alloc/ffi/c_str.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
#[rustversion::since(1.64)]
2+
use alloc::ffi::CString;
3+
#[rustversion::before(1.64)]
4+
use std::ffi::CString;
15
use {
26
crate::{Arbitrary, Result, Unstructured},
3-
alloc::{ffi::CString, vec::Vec},
7+
alloc::vec::Vec,
48
};
59

610
impl<'a> Arbitrary<'a> for CString {

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ impl core::fmt::Display for MaxRecursionReached {
5353
}
5454
}
5555

56+
#[rustversion::before(1.81)]
57+
impl std::error::Error for MaxRecursionReached {}
58+
59+
#[rustversion::since(1.81)]
5660
impl core::error::Error for MaxRecursionReached {}
5761

5862
/// Generate arbitrary structured values from raw, unstructured data.

0 commit comments

Comments
 (0)