Manuall impl Show for SqlState

The derive'd impl generates an incredibly bad implementation.

cc rust-lang/rust#20856
This commit is contained in:
Steven Fackler 2015-01-10 11:40:22 -08:00
parent 72a7544bee
commit 857f8ebd70

View File

@ -13,7 +13,7 @@ use types::Type;
macro_rules! make_errors {
($($code:expr => $error:ident),+) => (
/// SQLSTATE error codes
#[derive(PartialEq, Eq, Clone, Show)]
#[derive(PartialEq, Eq, Clone)]
#[allow(missing_docs)]
pub enum SqlState {
$($error,)+
@ -41,6 +41,16 @@ macro_rules! make_errors {
}
}
}
impl fmt::Show for SqlState {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let s = match *self {
$(SqlState::$error => stringify!($error),)+
SqlState::Unknown(ref s) => return write!(fmt, "Unknown({:?})", s),
};
fmt.write_str(s)
}
}
)
}