mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-26 00:04:32 +08:00
Replace try!
by ?
This commit is contained in:
@@ -131,7 +131,7 @@ impl ArrayTabCursor {
|
||||
impl VTabCursor for ArrayTabCursor {
|
||||
fn filter(&mut self, idx_num: c_int, _idx_str: Option<&str>, args: &Values) -> Result<()> {
|
||||
if idx_num > 0 {
|
||||
self.ptr = try!(args.get_array(0));
|
||||
self.ptr = args.get_array(0)?;
|
||||
} else {
|
||||
self.ptr = None;
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ impl CSVTab {
|
||||
}
|
||||
|
||||
fn parameter(c_slice: &[u8]) -> Result<(&str, &str)> {
|
||||
let arg = try!(str::from_utf8(c_slice)).trim();
|
||||
let arg = str::from_utf8(c_slice)?.trim();
|
||||
let mut split = arg.split('=');
|
||||
if let Some(key) = split.next() {
|
||||
if let Some(value) = split.next() {
|
||||
@@ -107,7 +107,7 @@ impl VTab for CSVTab {
|
||||
|
||||
let args = &args[3..];
|
||||
for c_slice in args {
|
||||
let (param, value) = try!(CSVTab::parameter(c_slice));
|
||||
let (param, value) = CSVTab::parameter(c_slice)?;
|
||||
match param {
|
||||
"filename" => {
|
||||
if !Path::new(value).exists() {
|
||||
@@ -189,10 +189,10 @@ impl VTab for CSVTab {
|
||||
|
||||
let mut cols: Vec<String> = Vec::new();
|
||||
if vtab.has_headers || (n_col.is_none() && schema.is_none()) {
|
||||
let mut reader = try!(vtab.reader());
|
||||
let mut reader = vtab.reader()?;
|
||||
if vtab.has_headers {
|
||||
{
|
||||
let headers = try!(reader.headers());
|
||||
let headers = reader.headers()?;
|
||||
// headers ignored if cols is not empty
|
||||
if n_col.is_none() && schema.is_none() {
|
||||
cols = headers
|
||||
@@ -204,7 +204,7 @@ impl VTab for CSVTab {
|
||||
vtab.offset_first_row = reader.position().clone();
|
||||
} else {
|
||||
let mut record = csv::ByteRecord::new();
|
||||
if try!(reader.read_byte_record(&mut record)) {
|
||||
if reader.read_byte_record(&mut record)? {
|
||||
for (i, _) in record.iter().enumerate() {
|
||||
cols.push(format!("c{}", i));
|
||||
}
|
||||
@@ -245,7 +245,7 @@ impl VTab for CSVTab {
|
||||
}
|
||||
|
||||
fn open(&self) -> Result<CSVTabCursor> {
|
||||
Ok(CSVTabCursor::new(try!(self.reader())))
|
||||
Ok(CSVTabCursor::new(self.reader()?))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ impl VTabCursor for CSVTabCursor {
|
||||
fn filter(&mut self, _idx_num: c_int, _idx_str: Option<&str>, _args: &Values) -> Result<()> {
|
||||
{
|
||||
let offset_first_row = self.vtab().offset_first_row.clone();
|
||||
try!(self.reader.seek(offset_first_row));
|
||||
self.reader.seek(offset_first_row)?;
|
||||
}
|
||||
self.row_number = 0;
|
||||
self.next()
|
||||
@@ -301,7 +301,7 @@ impl VTabCursor for CSVTabCursor {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.eof = !try!(self.reader.read_record(&mut self.cols));
|
||||
self.eof = !self.reader.read_record(&mut self.cols)?;
|
||||
}
|
||||
|
||||
self.row_number += 1;
|
||||
|
@@ -469,7 +469,7 @@ impl<'a> Values<'a> {
|
||||
FromSqlError::OutOfRange(i) => Error::IntegralValueOutOfRange(idx, i),
|
||||
#[cfg(feature = "i128_blob")]
|
||||
FromSqlError::InvalidI128Size(_) => Error::InvalidColumnType(idx, value.data_type()),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// `sqlite3_value_type` returns `SQLITE_NULL` for pointer.
|
||||
@@ -546,7 +546,7 @@ impl InnerConnection {
|
||||
module: &Module<T>,
|
||||
aux: Option<T::Aux>,
|
||||
) -> Result<()> {
|
||||
let c_name = try!(str_to_cstring(module_name));
|
||||
let c_name = str_to_cstring(module_name)?;
|
||||
let r = match aux {
|
||||
Some(aux) => {
|
||||
let boxed_aux: *mut T::Aux = Box::into_raw(Box::new(aux));
|
||||
|
@@ -188,19 +188,19 @@ impl VTabCursor for SeriesTabCursor {
|
||||
let idx_num = QueryPlanFlags::from_bits_truncate(idx_num);
|
||||
let mut i = 0;
|
||||
if idx_num.contains(QueryPlanFlags::START) {
|
||||
self.min_value = try!(args.get(i));
|
||||
self.min_value = args.get(i)?;
|
||||
i += 1;
|
||||
} else {
|
||||
self.min_value = 0;
|
||||
}
|
||||
if idx_num.contains(QueryPlanFlags::STOP) {
|
||||
self.max_value = try!(args.get(i));
|
||||
self.max_value = args.get(i)?;
|
||||
i += 1;
|
||||
} else {
|
||||
self.max_value = 0xffff_ffff;
|
||||
}
|
||||
if idx_num.contains(QueryPlanFlags::STEP) {
|
||||
self.step = try!(args.get(i));
|
||||
self.step = args.get(i)?;
|
||||
if self.step < 1 {
|
||||
self.step = 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user