From ac7920ef4b5c04833e30ad073b509b11bc9e42e4 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Wed, 3 Aug 2016 19:27:18 -0700 Subject: [PATCH] Don't use std --- src/iter.rs | 2 +- src/lib.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/iter.rs b/src/iter.rs index b5dc68a..425e6ec 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,4 +1,4 @@ -use std::slice; +use core::slice; pub struct Bytes<'a> { slice: &'a [u8], diff --git a/src/lib.rs b/src/lib.rs index febd1d9..11cad4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(not(test),no_std)] #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] //! # httparse @@ -13,7 +14,9 @@ //! 1.6 times slower than pico. Improvements can be made as a `likely` //! intrinsic, and simd, are stabilized in rustc. -use std::{str, slice}; +#[cfg(test)] extern crate core; + +use core::{str, slice}; use iter::Bytes; mod iter; @@ -118,7 +121,7 @@ pub struct InvalidChunkSize; /// If the input is invalid, an `Error` will be returned. Note that incomplete /// data is not considered invalid, and so will not return an error, but rather /// a `Ok(Status::Partial)`. -pub type Result = ::std::result::Result, Error>; +pub type Result = ::core::result::Result, Error>; /// The result of a successful parse pass. /// @@ -558,7 +561,7 @@ fn parse_headers_iter<'a, 'b>(headers: &mut &mut [Header<'a>], bytes: &'b mut By /// Ok(httparse::Status::Complete((3, 4)))); /// ``` pub fn parse_chunk_size(buf: &[u8]) - -> ::std::result::Result, InvalidChunkSize> { + -> ::core::result::Result, InvalidChunkSize> { const RADIX: u64 = 16; let mut bytes = Bytes::new(buf); let mut size = 0;