aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--README.md10
-rw-r--r--src/lib.rs13
3 files changed, 21 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 0e8fc7f..d198f8c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,8 @@ quickcheck = "0.2"
rand = "0.3"
[features]
-no-std = []
+default = ["std"]
+std = []
[profile.bench]
opt-level = 3
diff --git a/README.md b/README.md
index d92b434..5640f3e 100644
--- a/README.md
+++ b/README.md
@@ -47,3 +47,13 @@ let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());
```
+
+### `no_std` crates
+
+This crate has a feature, `std`, that is enabled by default. To use this crate
+in a `no_std` context, add the following to your `Cargo.toml`:
+
+```toml
+[dependencies]
+byteorder = { version = "0.5", default-features = false }
+```
diff --git a/src/lib.rs b/src/lib.rs
index a57ebfd..e4fddfe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,15 +39,20 @@ assert_eq!(wtr, vec![5, 2, 0, 3]);
#![crate_name = "byteorder"]
#![doc(html_root_url = "http://burntsushi.net/rustdoc/byteorder")]
+#![cfg_attr(not(feature = "std"), no_std)]
+
#![deny(missing_docs)]
-use std::mem::transmute;
-use std::ptr::copy_nonoverlapping;
+#[cfg(feature = "std")]
+extern crate core;
+
+use core::mem::transmute;
+use core::ptr::copy_nonoverlapping;
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
pub use new::{ReadBytesExt, WriteBytesExt};
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
mod new;
#[inline]