From 9918693037dce8aa4bb6f08741b6812923486c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:26:03 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/camino/src/lib.rs | 2 +- vendor/camino/src/serde_impls.rs | 46 ++++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'vendor/camino/src') diff --git a/vendor/camino/src/lib.rs b/vendor/camino/src/lib.rs index 86a58ee51..7a5c61c10 100644 --- a/vendor/camino/src/lib.rs +++ b/vendor/camino/src/lib.rs @@ -2055,7 +2055,7 @@ impl<'a> fmt::Display for Utf8PrefixComponent<'a> { /// Iterator over the entries in a directory. /// /// This iterator is returned from [`Utf8Path::read_dir_utf8`] and will yield instances of -/// [io::Result]<[Utf8DirEntry]>. Through a [`Utf8 DirEntry`] information like the entry's path +/// [io::Result]<[Utf8DirEntry]>. Through a [`Utf8DirEntry`] information like the entry's path /// and possibly other metadata can be learned. /// /// The order in which this iterator returns entries is platform and filesystem diff --git a/vendor/camino/src/serde_impls.rs b/vendor/camino/src/serde_impls.rs index 49b6f8621..1a7fa1b9e 100644 --- a/vendor/camino/src/serde_impls.rs +++ b/vendor/camino/src/serde_impls.rs @@ -6,7 +6,7 @@ //! The Serde implementations for `Utf8PathBuf` are derived, but `Utf8Path` is an unsized type which //! the derive impls can't handle. Implement these by hand. -use crate::Utf8Path; +use crate::{Utf8Path, Utf8PathBuf}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use std::fmt; @@ -36,7 +36,6 @@ impl<'a> de::Visitor<'a> for Utf8PathVisitor { } } -#[cfg(feature = "serde1")] impl<'de: 'a, 'a> Deserialize<'de> for &'a Utf8Path { fn deserialize(deserializer: D) -> Result where @@ -46,7 +45,6 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a Utf8Path { } } -#[cfg(feature = "serde1")] impl Serialize for Utf8Path { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +54,20 @@ impl Serialize for Utf8Path { } } +impl<'de> Deserialize<'de> for Box { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + Ok(Utf8PathBuf::deserialize(deserializer)?.into()) + } +} + +// impl Serialize for Box comes from impl Serialize for Utf8Path. + +// Can't provide impls for Arc/Rc due to orphan rule issues, but we could provide +// `with` impls in the future as requested. + #[cfg(test)] mod tests { use super::*; @@ -73,6 +85,7 @@ mod tests { assert_valid_utf8::(input, &encoded); assert_valid_utf8::(input, &encoded); + assert_valid_utf8::(input, &encoded); } } @@ -84,6 +97,8 @@ mod tests { "for input, with {}, paths should match", T::description() ); + let roundtrip = bincode::serialize(&output).expect("message should roundtrip"); + assert_eq!(roundtrip, encoded, "encoded path matches"); } #[test] @@ -101,7 +116,8 @@ mod tests { let encoded = bincode::serialize(&encode).expect("encoded correctly"); assert_invalid_utf8::(input, &encoded, *valid_up_to, *error_len); - assert_invalid_utf8::(input, &encoded, *valid_up_to, *error_len) + assert_invalid_utf8::(input, &encoded, *valid_up_to, *error_len); + assert_invalid_utf8::(input, &encoded, *valid_up_to, *error_len); } } @@ -142,12 +158,12 @@ mod tests { path: ByteBuf, } - trait TestTrait<'de>: Deserialize<'de> + fmt::Debug { + trait TestTrait<'de>: Serialize + Deserialize<'de> + fmt::Debug { fn description() -> &'static str; fn path(&self) -> &Utf8Path; } - #[derive(Deserialize, Debug)] + #[derive(Serialize, Deserialize, Debug)] #[allow(unused)] struct DecodeOwned { path: Utf8PathBuf, @@ -163,7 +179,7 @@ mod tests { } } - #[derive(Deserialize, Debug)] + #[derive(Serialize, Deserialize, Debug)] #[allow(unused)] struct DecodeBorrowed<'a> { #[serde(borrow)] @@ -179,4 +195,20 @@ mod tests { self.path } } + + #[derive(Serialize, Deserialize, Debug)] + #[allow(unused)] + struct DecodeBoxed { + path: Box, + } + + impl<'de> TestTrait<'de> for DecodeBoxed { + fn description() -> &'static str { + "DecodeBoxed" + } + + fn path(&self) -> &Utf8Path { + &self.path + } + } } -- cgit v1.2.3