Skip to content

Commit b32a3d5

Browse files
committed
Make library #![no_std] by default
1 parent ca3af4d commit b32a3d5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

deranged/src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
//! `deranged` is a proof-of-concept implementation of ranged integers.
22
33
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
4-
#![cfg_attr(not(feature = "std"), no_std)]
4+
#![no_std]
55
#![doc(test(attr(deny(warnings))))]
66

7+
#[cfg(feature = "std")]
8+
extern crate std;
9+
10+
#[cfg(feature = "alloc")]
11+
extern crate alloc;
12+
713
#[cfg(test)]
814
mod tests;
915
mod traits;
1016
mod unsafe_wrapper;
1117

12-
#[cfg(feature = "alloc")]
13-
#[allow(unused_extern_crates)]
14-
extern crate alloc;
15-
1618
use core::borrow::Borrow;
1719
use core::cmp::Ordering;
1820
use core::fmt;
@@ -1327,8 +1329,8 @@ macro_rules! impl_ranged {
13271329
let internal = <$internal>::deserialize(deserializer)?;
13281330
Self::new(internal).ok_or_else(|| <D::Error as serde::de::Error>::invalid_value(
13291331
serde::de::Unexpected::Other("integer"),
1330-
#[cfg(feature = "std")] {
1331-
&format!("an integer in the range {}..={}", MIN, MAX).as_ref()
1332+
#[cfg(feature = "alloc")] {
1333+
&alloc::format!("an integer in the range {}..={}", MIN, MAX).as_ref()
13321334
},
13331335
#[cfg(not(feature = "std"))] {
13341336
&"an integer in the valid range"

deranged/src/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use core::hash::Hash;
2+
use std::format;
3+
use std::prelude::rust_2021::*;
24

35
use crate::{
46
IntErrorKind, OptionRangedI128, OptionRangedI16, OptionRangedI32, OptionRangedI64,

0 commit comments

Comments
 (0)