Replace .err().unwrap() by .unwrap_err()

This commit is contained in:
gwenn 2022-04-07 09:17:42 +02:00
parent 214a6244f9
commit ad911efd15
2 changed files with 23 additions and 41 deletions

View File

@ -1288,7 +1288,7 @@ mod test {
let filename = "no_such_file.db";
let result = Connection::open_with_flags(filename, OpenFlags::SQLITE_OPEN_READ_ONLY);
assert!(result.is_err());
let err = result.err().unwrap();
let err = result.unwrap_err();
if let Error::SqliteFailure(e, Some(msg)) = err {
assert_eq!(ErrorCode::CannotOpen, e.code);
assert_eq!(ffi::SQLITE_CANTOPEN, e.extended_code);

View File

@ -272,85 +272,67 @@ mod test {
// check some invalid types
// 0 is actually a blob (Vec<u8>)
assert!(is_invalid_column_type(
row.get::<_, c_int>(0).err().unwrap()
));
assert!(is_invalid_column_type(
row.get::<_, c_int>(0).err().unwrap()
));
assert!(is_invalid_column_type(row.get::<_, c_int>(0).unwrap_err()));
assert!(is_invalid_column_type(row.get::<_, c_int>(0).unwrap_err()));
assert!(is_invalid_column_type(row.get::<_, i64>(0).err().unwrap()));
assert!(is_invalid_column_type(
row.get::<_, c_double>(0).err().unwrap()
));
assert!(is_invalid_column_type(
row.get::<_, String>(0).err().unwrap()
row.get::<_, c_double>(0).unwrap_err()
));
assert!(is_invalid_column_type(row.get::<_, String>(0).unwrap_err()));
#[cfg(feature = "time")]
assert!(is_invalid_column_type(
row.get::<_, time::OffsetDateTime>(0).err().unwrap()
row.get::<_, time::OffsetDateTime>(0).unwrap_err()
));
assert!(is_invalid_column_type(
row.get::<_, Option<c_int>>(0).err().unwrap()
row.get::<_, Option<c_int>>(0).unwrap_err()
));
// 1 is actually a text (String)
assert!(is_invalid_column_type(
row.get::<_, c_int>(1).err().unwrap()
));
assert!(is_invalid_column_type(row.get::<_, c_int>(1).unwrap_err()));
assert!(is_invalid_column_type(row.get::<_, i64>(1).err().unwrap()));
assert!(is_invalid_column_type(
row.get::<_, c_double>(1).err().unwrap()
row.get::<_, c_double>(1).unwrap_err()
));
assert!(is_invalid_column_type(
row.get::<_, Vec<u8>>(1).err().unwrap()
row.get::<_, Vec<u8>>(1).unwrap_err()
));
assert!(is_invalid_column_type(
row.get::<_, Option<c_int>>(1).err().unwrap()
row.get::<_, Option<c_int>>(1).unwrap_err()
));
// 2 is actually an integer
assert!(is_invalid_column_type(row.get::<_, String>(2).unwrap_err()));
assert!(is_invalid_column_type(
row.get::<_, String>(2).err().unwrap()
row.get::<_, Vec<u8>>(2).unwrap_err()
));
assert!(is_invalid_column_type(
row.get::<_, Vec<u8>>(2).err().unwrap()
));
assert!(is_invalid_column_type(
row.get::<_, Option<String>>(2).err().unwrap()
row.get::<_, Option<String>>(2).unwrap_err()
));
// 3 is actually a float (c_double)
assert!(is_invalid_column_type(
row.get::<_, c_int>(3).err().unwrap()
));
assert!(is_invalid_column_type(row.get::<_, c_int>(3).unwrap_err()));
assert!(is_invalid_column_type(row.get::<_, i64>(3).err().unwrap()));
assert!(is_invalid_column_type(row.get::<_, String>(3).unwrap_err()));
assert!(is_invalid_column_type(
row.get::<_, String>(3).err().unwrap()
row.get::<_, Vec<u8>>(3).unwrap_err()
));
assert!(is_invalid_column_type(
row.get::<_, Vec<u8>>(3).err().unwrap()
));
assert!(is_invalid_column_type(
row.get::<_, Option<c_int>>(3).err().unwrap()
row.get::<_, Option<c_int>>(3).unwrap_err()
));
// 4 is actually NULL
assert!(is_invalid_column_type(
row.get::<_, c_int>(4).err().unwrap()
));
assert!(is_invalid_column_type(row.get::<_, c_int>(4).unwrap_err()));
assert!(is_invalid_column_type(row.get::<_, i64>(4).err().unwrap()));
assert!(is_invalid_column_type(
row.get::<_, c_double>(4).err().unwrap()
row.get::<_, c_double>(4).unwrap_err()
));
assert!(is_invalid_column_type(row.get::<_, String>(4).unwrap_err()));
assert!(is_invalid_column_type(
row.get::<_, String>(4).err().unwrap()
));
assert!(is_invalid_column_type(
row.get::<_, Vec<u8>>(4).err().unwrap()
row.get::<_, Vec<u8>>(4).unwrap_err()
));
#[cfg(feature = "time")]
assert!(is_invalid_column_type(
row.get::<_, time::OffsetDateTime>(4).err().unwrap()
row.get::<_, time::OffsetDateTime>(4).unwrap_err()
));
Ok(())
}