Easier display impl in tests

This commit is contained in:
David Tolnay 2019-10-09 07:23:58 -07:00
parent fe4de24dcc
commit 3e7ddeb72d
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -1,6 +1,16 @@
use std::fmt::{self, Display};
use thiserror::Error;
macro_rules! unimplemented_display {
($ty:ty) => {
impl Display for $ty {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
};
}
#[derive(Error, Debug)]
struct BracedError {
msg: String,
@ -13,20 +23,6 @@ struct TupleError(String, usize);
#[derive(Error, Debug)]
struct UnitError;
impl Display for BracedError {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
impl Display for TupleError {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
impl Display for UnitError {
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
unimplemented!()
}
}
unimplemented_display!(BracedError);
unimplemented_display!(TupleError);
unimplemented_display!(UnitError);