From a3377041b829fb3127439551b7e990dab097fb37 Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Mon, 20 Nov 2023 14:21:39 -0500 Subject: [PATCH] Bump simd-json to 0.12 --- Cargo.toml | 2 +- src/json.rs | 12 +++++------- src/utils/token.rs | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 88b3210d003..66b6f5465ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ version = "1.0.7" optional = true [dependencies.simd-json] -version = "0.4.14" +version = "0.12.0" optional = true [dependencies.tracing] diff --git a/src/json.rs b/src/json.rs index fc7f9031df0..3fcc69a366e 100644 --- a/src/json.rs +++ b/src/json.rs @@ -5,8 +5,6 @@ use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; -#[cfg(feature = "gateway")] -use serde::de::Deserialize; use serde::de::DeserializeOwned; use serde::ser::Serialize; @@ -62,19 +60,19 @@ where } #[cfg(all(feature = "gateway", not(feature = "simd_json")))] -pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result +pub(crate) fn from_str<'a, T>(s: &'a str) -> Result where - T: Deserialize<'a>, + T: serde::de::Deserialize<'a>, { Ok(serde_json::from_str(s)?) } #[cfg(all(feature = "gateway", feature = "simd_json"))] -pub(crate) fn from_str<'a, T>(s: &'a mut str) -> Result +pub(crate) fn from_str(s: &str) -> Result where - T: Deserialize<'a>, + T: DeserializeOwned, { - Ok(simd_json::from_str(s)?) + Ok(simd_json::from_slice(&mut s.to_owned().into_bytes())?) } #[cfg(not(feature = "simd_json"))] diff --git a/src/utils/token.rs b/src/utils/token.rs index 63c3062dc4d..dd90bd046d4 100644 --- a/src/utils/token.rs +++ b/src/utils/token.rs @@ -20,7 +20,7 @@ use crate::model::id::UserId; /// Validate that a token is valid and that a number of malformed tokens are /// actually invalid: /// -/// ``` +/// ```rust,no_run /// use serenity::utils::token::validate; /// /// // ensure a valid token is in fact a valid format: