Manuall impl Show for SqlState
The derive'd impl generates an incredibly bad implementation. cc rust-lang/rust#20856
This commit is contained in:
parent
72a7544bee
commit
857f8ebd70
12
src/error.rs
12
src/error.rs
@ -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)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user