Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/serde_spanned/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ pre-release-replacements = [

[features]
default = ["std", "serde"]
alloc = ["serde?/alloc"]
std = ["alloc", "serde?/std"]
serde = ["dep:serde"]
alloc = ["serde_core?/alloc"]
std = ["alloc", "serde_core?/std"]
serde = ["dep:serde_core"]

[dependencies]
serde = { version = "1.0.145", optional = true, default-features = false }
serde_core = { version = "1.0.221", optional = true, default-features = false }

[dev-dependencies]
serde = "1"
Expand Down
22 changes: 11 additions & 11 deletions crates/serde_spanned/src/de.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Deserialzation support for [`Spanned`]

use serde::de::value::BorrowedStrDeserializer;
use serde::de::IntoDeserializer as _;
use serde_core::de::value::BorrowedStrDeserializer;
use serde_core::de::IntoDeserializer as _;

use crate::Spanned;

Expand All @@ -13,8 +13,8 @@ pub fn is_spanned(name: &'static str) -> bool {
/// Deserializer / format support for emitting [`Spanned`]
pub struct SpannedDeserializer<'de, T, E>
where
T: serde::de::IntoDeserializer<'de, E>,
E: serde::de::Error,
T: serde_core::de::IntoDeserializer<'de, E>,
E: serde_core::de::Error,
{
start: Option<usize>,
end: Option<usize>,
Expand All @@ -25,8 +25,8 @@ where

impl<'de, T, E> SpannedDeserializer<'de, T, E>
where
T: serde::de::IntoDeserializer<'de, E>,
E: serde::de::Error,
T: serde_core::de::IntoDeserializer<'de, E>,
E: serde_core::de::Error,
{
/// Create a deserializer to emit [`Spanned`]
pub fn new(value: T, span: core::ops::Range<usize>) -> Self {
Expand All @@ -40,15 +40,15 @@ where
}
}

impl<'de, T, E> serde::de::MapAccess<'de> for SpannedDeserializer<'de, T, E>
impl<'de, T, E> serde_core::de::MapAccess<'de> for SpannedDeserializer<'de, T, E>
where
T: serde::de::IntoDeserializer<'de, E>,
E: serde::de::Error,
T: serde_core::de::IntoDeserializer<'de, E>,
E: serde_core::de::Error,
{
type Error = E;
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
where
K: serde::de::DeserializeSeed<'de>,
K: serde_core::de::DeserializeSeed<'de>,
{
if self.start.is_some() {
seed.deserialize(BorrowedStrDeserializer::new(Spanned::<T>::START_FIELD))
Expand All @@ -66,7 +66,7 @@ where

fn next_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
where
V: serde::de::DeserializeSeed<'de>,
V: serde_core::de::DeserializeSeed<'de>,
{
if let Some(start) = self.start.take() {
seed.deserialize(start.into_deserializer())
Expand Down
30 changes: 15 additions & 15 deletions crates/serde_spanned/src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ impl<T: Ord> Ord for Spanned<T> {
}

#[cfg(feature = "serde")]
impl<'de, T> serde::de::Deserialize<'de> for Spanned<T>
impl<'de, T> serde_core::de::Deserialize<'de> for Spanned<T>
where
T: serde::de::Deserialize<'de>,
T: serde_core::de::Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::de::Deserializer<'de>,
D: serde_core::de::Deserializer<'de>,
{
struct SpannedVisitor<T>(::core::marker::PhantomData<T>);

impl<'de, T> serde::de::Visitor<'de> for SpannedVisitor<T>
impl<'de, T> serde_core::de::Visitor<'de> for SpannedVisitor<T>
where
T: serde::de::Deserialize<'de>,
T: serde_core::de::Deserialize<'de>,
{
type Value = Spanned<T>;

Expand All @@ -197,7 +197,7 @@ where

fn visit_map<V>(self, mut visitor: V) -> Result<Spanned<T>, V::Error>
where
V: serde::de::MapAccess<'de>,
V: serde_core::de::MapAccess<'de>,
{
let mut start: Option<usize> = None;
let mut end: Option<usize> = None;
Expand All @@ -206,24 +206,24 @@ where
match key {
START_FIELD => {
if start.is_some() {
return Err(serde::de::Error::duplicate_field(START_FIELD));
return Err(serde_core::de::Error::duplicate_field(START_FIELD));
}
start = Some(visitor.next_value()?);
}
END_FIELD => {
if end.is_some() {
return Err(serde::de::Error::duplicate_field(END_FIELD));
return Err(serde_core::de::Error::duplicate_field(END_FIELD));
}
end = Some(visitor.next_value()?);
}
VALUE_FIELD => {
if value.is_some() {
return Err(serde::de::Error::duplicate_field(VALUE_FIELD));
return Err(serde_core::de::Error::duplicate_field(VALUE_FIELD));
}
value = Some(visitor.next_value()?);
}
field => {
return Err(serde::de::Error::unknown_field(
return Err(serde_core::de::Error::unknown_field(
field,
&[START_FIELD, END_FIELD, VALUE_FIELD],
));
Expand All @@ -235,9 +235,9 @@ where
span: start..end,
value,
}),
(None, _, _) => Err(serde::de::Error::missing_field(START_FIELD)),
(_, None, _) => Err(serde::de::Error::missing_field(END_FIELD)),
(_, _, None) => Err(serde::de::Error::missing_field(VALUE_FIELD)),
(None, _, _) => Err(serde_core::de::Error::missing_field(START_FIELD)),
(_, None, _) => Err(serde_core::de::Error::missing_field(END_FIELD)),
(_, _, None) => Err(serde_core::de::Error::missing_field(VALUE_FIELD)),
}
}
}
Expand All @@ -251,10 +251,10 @@ where
}

#[cfg(feature = "serde")]
impl<T: serde::ser::Serialize> serde::ser::Serialize for Spanned<T> {
impl<T: serde_core::ser::Serialize> serde_core::ser::Serialize for Spanned<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
S: serde_core::ser::Serializer,
{
self.value.serialize(serializer)
}
Expand Down
6 changes: 3 additions & 3 deletions crates/toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pre-release-replacements = [

[features]
default = ["std", "serde", "parse", "display"]
std = ["indexmap?/std", "serde?/std", "toml_parser?/std", "toml_writer?/std", "toml_datetime/std", "serde_spanned/std"]
serde = ["dep:serde", "toml_datetime/serde", "serde_spanned/serde"]
std = ["indexmap?/std", "serde_core?/std", "toml_parser?/std", "toml_writer?/std", "toml_datetime/std", "serde_spanned/std"]
serde = ["dep:serde_core", "toml_datetime/serde", "serde_spanned/serde"]
parse = ["dep:toml_parser", "dep:winnow"]
display = ["dep:toml_writer"]
fast_hash = ["preserve_order", "dep:foldhash"]
Expand All @@ -49,7 +49,7 @@ unbounded = []
preserve_order = ["dep:indexmap", "std"]

[dependencies]
serde = { version = "1.0.145", default-features = false, features = ["alloc"], optional = true }
serde_core = { version = "1.0.221", default-features = false, features = ["alloc"], optional = true }
indexmap = { version = "2.3.0", default-features = false, optional = true }
toml_parser = { version = "1.0.2", path = "../toml_parser", default-features = false, features = ["alloc"], optional = true }
winnow = { version = "0.7.10", default-features = false, optional = true }
Expand Down
14 changes: 7 additions & 7 deletions crates/toml/src/de/deserializer/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ impl<'i> ArrayDeserializer<'i> {
}
}

impl<'de> serde::Deserializer<'de> for ArrayDeserializer<'de> {
impl<'de> serde_core::Deserializer<'de> for ArrayDeserializer<'de> {
type Error = Error;

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: serde::de::Visitor<'de>,
V: serde_core::de::Visitor<'de>,
{
visitor.visit_seq(ArraySeqAccess::new(self.input))
}
Expand All @@ -32,7 +32,7 @@ impl<'de> serde::Deserializer<'de> for ArrayDeserializer<'de> {
visitor: V,
) -> Result<V::Value, Error>
where
V: serde::de::Visitor<'de>,
V: serde_core::de::Visitor<'de>,
{
if serde_spanned::de::is_spanned(name) {
let span = self.span.clone();
Expand All @@ -42,14 +42,14 @@ impl<'de> serde::Deserializer<'de> for ArrayDeserializer<'de> {
self.deserialize_any(visitor)
}

serde::forward_to_deserialize_any! {
serde_core::forward_to_deserialize_any! {
bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string seq
bytes byte_buf map option unit newtype_struct
ignored_any unit_struct tuple_struct tuple enum identifier
}
}

impl<'de> serde::de::IntoDeserializer<'de, Error> for ArrayDeserializer<'de> {
impl<'de> serde_core::de::IntoDeserializer<'de, Error> for ArrayDeserializer<'de> {
type Deserializer = Self;

fn into_deserializer(self) -> Self::Deserializer {
Expand All @@ -69,12 +69,12 @@ impl<'i> ArraySeqAccess<'i> {
}
}

impl<'de> serde::de::SeqAccess<'de> for ArraySeqAccess<'de> {
impl<'de> serde_core::de::SeqAccess<'de> for ArraySeqAccess<'de> {
type Error = Error;

fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
where
T: serde::de::DeserializeSeed<'de>,
T: serde_core::de::DeserializeSeed<'de>,
{
match self.iter.next() {
Some(v) => {
Expand Down
Loading
Loading