diff options
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | src/lib.rs | 13 |
3 files changed, 21 insertions, 5 deletions
@@ -18,7 +18,8 @@ quickcheck = "0.2" rand = "0.3" [features] -no-std = [] +default = ["std"] +std = [] [profile.bench] opt-level = 3 @@ -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 } +``` @@ -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] |