mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-22 22:34:28 +08:00
Simplify InvalidType
This commit is contained in:
@@ -24,7 +24,7 @@ impl FromSql for f64 {
|
||||
match value {
|
||||
ValueRef::Integer(i) => Ok(i as f64),
|
||||
ValueRef::Real(f) => Ok(f),
|
||||
_ => Err(Error::InvalidType(value.data_type())),
|
||||
_ => Err(Error::InvalidType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ impl FromSql for Value {
|
||||
match value {
|
||||
ValueRef::Text(ref s) => serde_json::from_str(s),
|
||||
ValueRef::Blob(ref b) => serde_json::from_slice(b),
|
||||
_ => return Err(Error::InvalidType(value.data_type())),
|
||||
_ => return Err(Error::InvalidType),
|
||||
}
|
||||
.map_err(|err| Error::FromSqlConversionFailure(Box::new(err)))
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ impl<'a> ValueRef<'a> {
|
||||
pub fn as_i64(&self) -> Result<i64> {
|
||||
match *self {
|
||||
ValueRef::Integer(i) => Ok(i),
|
||||
_ => Err(Error::InvalidType(self.data_type())),
|
||||
_ => Err(Error::InvalidType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl<'a> ValueRef<'a> {
|
||||
pub fn as_f64(&self) -> Result<f64> {
|
||||
match *self {
|
||||
ValueRef::Real(f) => Ok(f),
|
||||
_ => Err(Error::InvalidType(self.data_type())),
|
||||
_ => Err(Error::InvalidType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ impl<'a> ValueRef<'a> {
|
||||
pub fn as_str(&self) -> Result<&str> {
|
||||
match *self {
|
||||
ValueRef::Text(ref t) => Ok(t),
|
||||
_ => Err(Error::InvalidType(self.data_type())),
|
||||
_ => Err(Error::InvalidType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ impl<'a> ValueRef<'a> {
|
||||
pub fn as_blob(&self) -> Result<&[u8]> {
|
||||
match *self {
|
||||
ValueRef::Blob(ref b) => Ok(b),
|
||||
_ => Err(Error::InvalidType(self.data_type())),
|
||||
_ => Err(Error::InvalidType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user