From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/thiserror/src/display.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'vendor/thiserror/src/display.rs') diff --git a/vendor/thiserror/src/display.rs b/vendor/thiserror/src/display.rs index da4905115..27098f167 100644 --- a/vendor/thiserror/src/display.rs +++ b/vendor/thiserror/src/display.rs @@ -2,29 +2,39 @@ use std::fmt::Display; use std::path::{self, Path, PathBuf}; #[doc(hidden)] -pub trait DisplayAsDisplay { - fn as_display(&self) -> Self; +pub trait AsDisplay<'a> { + // TODO: convert to generic associated type. + // https://github.com/dtolnay/thiserror/pull/253 + type Target: Display; + + fn as_display(&'a self) -> Self::Target; } -impl DisplayAsDisplay for &T { - fn as_display(&self) -> Self { - self +impl<'a, T> AsDisplay<'a> for &T +where + T: Display + 'a, +{ + type Target = &'a T; + + fn as_display(&'a self) -> Self::Target { + *self } } -#[doc(hidden)] -pub trait PathAsDisplay { - fn as_display(&self) -> path::Display<'_>; -} +impl<'a> AsDisplay<'a> for Path { + type Target = path::Display<'a>; -impl PathAsDisplay for Path { - fn as_display(&self) -> path::Display<'_> { + #[inline] + fn as_display(&'a self) -> Self::Target { self.display() } } -impl PathAsDisplay for PathBuf { - fn as_display(&self) -> path::Display<'_> { +impl<'a> AsDisplay<'a> for PathBuf { + type Target = path::Display<'a>; + + #[inline] + fn as_display(&'a self) -> Self::Target { self.display() } } -- cgit v1.2.3