Skip to content

Commit

Permalink
Use 'dep' syntax for 'http' features.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Apr 26, 2024
1 parent 84072a8 commit e6aaea0
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 49 deletions.
10 changes: 4 additions & 6 deletions core/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ rust-version = "1.75"

[features]
default = []
serde = ["uncased/with-serde-alloc", "serde_"]
uuid = ["uuid_"]
serde = ["dep:serde", "uncased/with-serde-alloc"]
uuid = ["dep:uuid"]

[lints.clippy]
module_inception = "allow"
Expand All @@ -39,15 +39,13 @@ stable-pattern = "0.1"
cookie = { version = "0.18", features = ["percent-encode"] }
state = "0.6"

[dependencies.serde_]
package = "serde"
[dependencies.serde]
version = "1.0"
optional = true
default-features = false
features = ["std"]

[dependencies.uuid_]
package = "uuid"
[dependencies.uuid]
version = "1"
optional = true
default-features = false
Expand Down
13 changes: 6 additions & 7 deletions core/http/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ macro_rules! define_methods {
/// from either `"GET"` or `"get"` but not `"GeT"`.
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// use serde::{Serialize, Deserialize};
/// # #[cfg(feature = "serde")] mod serde_impl {
/// use rocket::http::Method;
/// use rocket::serde::{Serialize, Deserialize};
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// #[serde(crate = "rocket::serde")]
/// struct Foo {
/// method: Method,
/// }
Expand Down Expand Up @@ -357,11 +356,11 @@ impl PartialEq<Method> for &Method {
}

#[cfg(feature = "serde")]
mod serde {
mod serde_impl {
use super::*;

use serde_::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};
use serde::ser::{Serialize, Serializer};
use serde::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};

impl Serialize for Method {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
Expand Down
4 changes: 2 additions & 2 deletions core/http/src/raw_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ impl RawStr {
}

#[cfg(feature = "serde")]
mod serde {
use serde_::{ser, de, Serialize, Deserialize};
mod serde_impl {
use serde::{ser, de, Serialize, Deserialize};

use super::*;

Expand Down
12 changes: 6 additions & 6 deletions core/http/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ impl StatusClass {
/// range `[100, 600)` is allowed to deserialize into a `Status`.`
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::Status;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct Foo {
/// status: Status,
/// }
Expand Down Expand Up @@ -381,11 +381,11 @@ impl Ord for Status {
}

#[cfg(feature = "serde")]
mod serde {
mod serde_impl {
use super::*;

use serde_::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};
use serde::ser::{Serialize, Serializer};
use serde::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};

impl Serialize for Status {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
Expand Down
8 changes: 4 additions & 4 deletions core/http/src/uri/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ use crate::uri::{Authority, Path, Query, Data, Error, as_utf8_unchecked, fmt};
/// `Absolute` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Absolute;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Absolute<'static>,
/// }
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> {
/// uri: Absolute<'a>,
/// }
Expand Down
6 changes: 3 additions & 3 deletions core/http/src/uri/asterisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use crate::uri::Error;
/// `Asterisk` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Asterisk;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Asterisk,
/// }
Expand Down
8 changes: 4 additions & 4 deletions core/http/src/uri/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ use crate::uri::{as_utf8_unchecked, error::Error};
/// `Authority` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Authority;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Authority<'static>,
/// }
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> {
/// uri: Authority<'a>,
/// }
Expand Down
4 changes: 2 additions & 2 deletions core/http/src/uri/fmt/uri_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ impl<K: UriDisplay<Query>, V: UriDisplay<Query>> UriDisplay<Query> for BTreeMap<
}
}

#[cfg(feature = "uuid")] impl_with_display!(uuid_::Uuid);
#[cfg(feature = "uuid")] crate::impl_from_uri_param_identity!(uuid_::Uuid);
#[cfg(feature = "uuid")] impl_with_display!(uuid::Uuid);
#[cfg(feature = "uuid")] crate::impl_from_uri_param_identity!(uuid::Uuid);

// And finally, the `Ignorable` trait, which has sugar of `_` in the `uri!`
// macro, which expands to a typecheck.
Expand Down
8 changes: 4 additions & 4 deletions core/http/src/uri/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ use crate::uri::{Absolute, Authority};
/// `Host` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Host;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Host<'static>,
/// }
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> {
/// uri: Host<'a>,
/// }
Expand Down
8 changes: 4 additions & 4 deletions core/http/src/uri/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ use crate::{RawStr, RawStrBuf};
/// `Origin` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Origin;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Origin<'static>,
/// }
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> {
/// uri: Origin<'a>,
/// }
Expand Down
8 changes: 4 additions & 4 deletions core/http/src/uri/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ use crate::parse::{Extent, IndexedStr};
/// `Reference` is both `Serialize` and `Deserialize`:
///
/// ```rust
/// # #[cfg(feature = "serde")] mod serde {
/// # use serde_ as serde;
/// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Reference;
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriOwned {
/// uri: Reference<'static>,
/// }
///
/// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")]
/// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> {
/// uri: Reference<'a>,
/// }
Expand Down
6 changes: 3 additions & 3 deletions core/http/src/uri/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ impl_uri_from!(Asterisk);
macro_rules! impl_serde {
($T:ty, $expected:literal) => {
#[cfg(feature = "serde")]
mod serde {
mod serde_impl {
use std::fmt;
use std::marker::PhantomData;
use super::*;

use serde_::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor};
use serde::ser::{Serialize, Serializer};
use serde::de::{Deserialize, Deserializer, Error, Visitor};

impl<'a> Serialize for $T {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
Expand Down

0 comments on commit e6aaea0

Please sign in to comment.