feature gate no_std

This commit is contained in:
Robin Appelman 2024-12-12 00:09:54 +01:00
commit 432d2393cb
3 changed files with 28 additions and 7 deletions

View file

@ -11,3 +11,7 @@ rust-version = "1.56.1"
[dependencies] [dependencies]
uncased = "0.9.10" uncased = "0.9.10"
[features]
std = []
default = ["std"]

View file

@ -18,4 +18,10 @@ for node_result in parse(header_value) {
} }
``` ```
## `no_std`
This crate can be used in a `no_std` environment by disabling the default `std` feature.
The only impact disabling this feature has is using `core::error::Error` and `core::net::IpAddr` instead of the `std` variants and increasing the msrv to 1.81.
[rfc7239]: https://tools.ietf.org/html/rfc7239 [rfc7239]: https://tools.ietf.org/html/rfc7239

View file

@ -1,4 +1,5 @@
#![no_std] #![cfg_attr(not(feature = "std"), no_std)]
//! Parser for [rfc7239] formatted `Forwarded` headers. //! Parser for [rfc7239] formatted `Forwarded` headers.
//! //!
//! ## Usage //! ## Usage
@ -23,15 +24,25 @@
//! //!
//! [rfc7239]: https://tools.ietf.org/html/rfc7239 //! [rfc7239]: https://tools.ietf.org/html/rfc7239
#[cfg(test)] #[cfg(all(test, not(feature = "std")))]
extern crate std; extern crate std;
#[cfg(test)] #[cfg(all(test, not(feature = "std")))]
use std::{format, vec, vec::Vec}; use std::{format, vec, vec::Vec};
use core::error::Error; #[cfg(not(feature = "std"))]
use core::fmt::{Debug, Display, Formatter}; use core::{
use core::net::IpAddr; error::Error,
use core::str::FromStr; fmt::{Debug, Display, Formatter},
net::IpAddr,
str::FromStr,
};
#[cfg(feature = "std")]
use std::{
error::Error,
fmt::{Debug, Display, Formatter},
net::IpAddr,
str::FromStr,
};
use uncased::UncasedStr; use uncased::UncasedStr;
#[derive(Debug)] #[derive(Debug)]