Merge pull request #350 from dtolnay/rawsource

Add test of r#source that is not Error::source
This commit is contained in:
David Tolnay 2024-11-04 16:38:31 -05:00 committed by GitHub
commit ef191b1048
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,3 +63,20 @@ error_from_macro! {
#[error("Something")]
Variant(#[from] io::Error)
}
#[test]
fn test_not_source() {
#[derive(Error, Debug)]
#[error("{source} ==> {destination}")]
pub struct NotSource {
r#source: char,
destination: char,
}
let error = NotSource {
source: 'S',
destination: 'D',
};
assert_eq!(error.to_string(), "S ==> D");
assert!(error.source().is_none());
}