Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dynamically sized field in error #375

Merged
merged 2 commits into from
Nov 8, 2024
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
4 changes: 2 additions & 2 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait AsDisplay<'a>: Sealed {

impl<'a, T> AsDisplay<'a> for &T
where
T: Display + 'a,
T: Display + ?Sized + 'a,
{
type Target = &'a T;

Expand Down Expand Up @@ -44,7 +44,7 @@ impl<'a> AsDisplay<'a> for PathBuf {

#[doc(hidden)]
pub trait Sealed {}
impl<T: Display> Sealed for &T {}
impl<T: Display + ?Sized> Sealed for &T {}
#[cfg(feature = "std")]
impl Sealed for Path {}
#[cfg(feature = "std")]
Expand Down
7 changes: 7 additions & 0 deletions tests/test_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ enum EnumPathBuf {
Read(PathBuf),
}

#[derive(Error, Debug)]
#[error("{tail}")]
pub struct UnsizedError {
pub head: i32,
pub tail: str,
}

fn assert<T: Display>(expected: &str, value: T) {
assert_eq!(expected, value.to_string());
}
Expand Down
Loading