summaryrefslogtreecommitdiffstats
path: root/vendor/camino/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/camino/src
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/camino/src')
-rw-r--r--vendor/camino/src/lib.rs2
-rw-r--r--vendor/camino/src/serde_impls.rs46
2 files changed, 40 insertions, 8 deletions
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
-/// <code>[io::Result]<[Utf8DirEntry]></code>. Through a [`Utf8 DirEntry`] information like the entry's path
+/// <code>[io::Result]<[Utf8DirEntry]></code>. 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<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -46,7 +45,6 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a Utf8Path {
}
}
-#[cfg(feature = "serde1")]
impl Serialize for Utf8Path {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -56,6 +54,20 @@ impl Serialize for Utf8Path {
}
}
+impl<'de> Deserialize<'de> for Box<Utf8Path> {
+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ Ok(Utf8PathBuf::deserialize(deserializer)?.into())
+ }
+}
+
+// impl Serialize for Box<Utf8Path> 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::<DecodeOwned>(input, &encoded);
assert_valid_utf8::<DecodeBorrowed>(input, &encoded);
+ assert_valid_utf8::<DecodeBoxed>(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::<DecodeOwned>(input, &encoded, *valid_up_to, *error_len);
- assert_invalid_utf8::<DecodeBorrowed>(input, &encoded, *valid_up_to, *error_len)
+ assert_invalid_utf8::<DecodeBorrowed>(input, &encoded, *valid_up_to, *error_len);
+ assert_invalid_utf8::<DecodeBoxed>(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<Utf8Path>,
+ }
+
+ impl<'de> TestTrait<'de> for DecodeBoxed {
+ fn description() -> &'static str {
+ "DecodeBoxed"
+ }
+
+ fn path(&self) -> &Utf8Path {
+ &self.path
+ }
+ }
}