From e0e90cdbf6a5582e4eb57dcf3cf48d3db6c158ae Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Mon, 16 Oct 2023 13:50:27 -0400 Subject: [PATCH] Replace uses of `simd-json` feature with `simd_json` --- .github/workflows/ci.yml | 2 +- src/error.rs | 6 ++-- src/internal/prelude.rs | 2 +- src/json.rs | 46 ++++++++++++++--------------- src/model/guild/audit_log/change.rs | 2 +- src/model/guild/mod.rs | 4 +-- src/model/guild/partial_guild.rs | 4 +-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c5cc1c36eb..95b7322c6fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: no cache features: builder client framework gateway model http standard_framework utils rustls_backend - name: simd-json - features: default_no_backend rustls_backend simd-json + features: default_no_backend rustls_backend simd_json - name: no gateway features: model http rustls_backend - name: time diff --git a/src/error.rs b/src/error.rs index 88dfbb3939f..ee73b8c5981 100644 --- a/src/error.rs +++ b/src/error.rs @@ -45,7 +45,7 @@ pub enum Error { Io(IoError), /// An error from the [`serde_json`] crate. Json(JsonError), - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] /// An error from the `simd_json` crate. SimdJson(simd_json::Error), /// An error from the [`model`] module. @@ -101,7 +101,7 @@ pub enum Error { Tungstenite(TungsteniteError), } -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] impl From for Error { fn from(e: simd_json::Error) -> Self { Error::SimdJson(e) @@ -178,7 +178,7 @@ impl fmt::Display for Error { Self::Json(inner) => fmt::Display::fmt(&inner, f), Self::Model(inner) => fmt::Display::fmt(&inner, f), Self::Url(msg) => f.write_str(msg), - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] Error::SimdJson(inner) => fmt::Display::fmt(&inner, f), #[cfg(feature = "client")] Self::Client(inner) => fmt::Display::fmt(&inner, f), diff --git a/src/internal/prelude.rs b/src/internal/prelude.rs index e5ac1c4332f..031f418ee1d 100644 --- a/src/internal/prelude.rs +++ b/src/internal/prelude.rs @@ -6,7 +6,7 @@ pub use std::result::Result as StdResult; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub use simd_json::{Mutable, Value as ValueTrait, ValueAccess}; #[cfg(feature = "client")] diff --git a/src/json.rs b/src/json.rs index 7b3ec970925..fc7f9031df0 100644 --- a/src/json.rs +++ b/src/json.rs @@ -12,28 +12,28 @@ use serde::ser::Serialize; use crate::Result; -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub type Value = serde_json::Value; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub type Value = simd_json::OwnedValue; -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub use serde_json::json; -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub use serde_json::Error as JsonError; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub use simd_json::json; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub use simd_json::Error as JsonError; -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub type JsonMap = serde_json::Map; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub type JsonMap = simd_json::owned::Object; -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub const NULL: Value = Value::Null; -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub const NULL: Value = Value::Static(simd_json::StaticNode::Null); /// Converts a HashMap into a final [`JsonMap`] representation. @@ -45,7 +45,7 @@ where map.into_iter().map(|(k, v)| (k.to_string(), v)).collect() } -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub(crate) fn to_string(v: &T) -> Result where T: Serialize, @@ -53,7 +53,7 @@ where Ok(serde_json::to_string(v)?) } -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub(crate) fn to_string(v: &T) -> Result where T: Serialize, @@ -61,7 +61,7 @@ where Ok(simd_json::to_string(v)?) } -#[cfg(all(feature = "gateway", not(feature = "simd-json")))] +#[cfg(all(feature = "gateway", not(feature = "simd_json")))] pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result where T: Deserialize<'a>, @@ -69,7 +69,7 @@ where Ok(serde_json::from_str(s)?) } -#[cfg(all(feature = "gateway", feature = "simd-json"))] +#[cfg(all(feature = "gateway", feature = "simd_json"))] pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result where T: Deserialize<'a>, @@ -77,7 +77,7 @@ where Ok(simd_json::from_str(s)?) } -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] pub(crate) fn from_value(v: Value) -> Result where T: DeserializeOwned, @@ -85,7 +85,7 @@ where Ok(serde_json::from_value(v)?) } -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] pub(crate) fn from_value(v: Value) -> Result where T: DeserializeOwned, @@ -93,7 +93,7 @@ where Ok(simd_json::serde::from_owned_value(v)?) } -#[cfg(all(any(feature = "builder", feature = "http"), not(feature = "simd-json")))] +#[cfg(all(any(feature = "builder", feature = "http"), not(feature = "simd_json")))] pub(crate) fn to_value(value: T) -> Result where T: Serialize, @@ -101,7 +101,7 @@ where Ok(serde_json::to_value(value)?) } -#[cfg(all(any(feature = "builder", feature = "http"), feature = "simd-json"))] +#[cfg(all(any(feature = "builder", feature = "http"), feature = "simd_json"))] pub(crate) fn to_value(value: T) -> Result where T: Serialize, @@ -113,14 +113,14 @@ pub trait ToNumber { fn to_number(self) -> Value; } -#[cfg(not(feature = "simd-json"))] +#[cfg(not(feature = "simd_json"))] impl> ToNumber for T { fn to_number(self) -> Value { Value::Number(self.into()) } } -#[cfg(feature = "simd-json")] +#[cfg(feature = "simd_json")] impl> ToNumber for T { fn to_number(self) -> Value { self.into() @@ -132,7 +132,7 @@ pub(crate) fn from_number(n: impl ToNumber) -> Value { } pub mod prelude { - #[cfg(not(feature = "simd-json"))] + #[cfg(not(feature = "simd_json"))] pub use serde_json::{ from_reader, from_slice, @@ -144,7 +144,7 @@ pub mod prelude { to_vec, to_vec_pretty, }; - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] pub use simd_json::{ from_reader, from_slice, @@ -156,7 +156,7 @@ pub mod prelude { to_vec, to_vec_pretty, }; - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] pub use simd_json::{Builder, Mutable, StaticNode, Value as ValueTrait, ValueAccess}; pub use super::*; diff --git a/src/model/guild/audit_log/change.rs b/src/model/guild/audit_log/change.rs index 300598690c8..19ddfdaa65a 100644 --- a/src/model/guild/audit_log/change.rs +++ b/src/model/guild/audit_log/change.rs @@ -34,7 +34,7 @@ pub enum EntityType { #[derive(Debug, PartialEq)] // serde_json's Value impls Eq, simd-json's Value doesn't -#[cfg_attr(not(feature = "simd-json"), derive(Eq))] +#[cfg_attr(not(feature = "simd_json"), derive(Eq))] #[non_exhaustive] pub enum Change { Actions { diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index e1a38f9d737..fa31247c428 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -2831,9 +2831,9 @@ impl<'de> Deserialize<'de> for Guild { None => PremiumTier::default(), }; let premium_subscription_count = match map.remove("premium_subscription_count") { - #[cfg(not(feature = "simd-json"))] + #[cfg(not(feature = "simd_json"))] Some(Value::Null) | None => 0, - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] Some(Value::Static(StaticNode::Null)) | None => 0, Some(v) => u64::deserialize(v).map_err(DeError::custom)?, }; diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index 968d0a9e196..db500cffefa 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -1734,9 +1734,9 @@ impl<'de> Deserialize<'de> for PartialGuild { None => PremiumTier::default(), }; let premium_subscription_count = match map.remove("premium_subscription_count") { - #[cfg(not(feature = "simd-json"))] + #[cfg(not(feature = "simd_json"))] Some(Value::Null) | None => 0, - #[cfg(feature = "simd-json")] + #[cfg(feature = "simd_json")] Some(Value::Static(StaticNode::Null)) | None => 0, Some(v) => u64::deserialize(v).map_err(DeError::custom)?, };