fix: do not swallow errors in (get|take)_opt methods
@@ -662,13 +662,13 @@ impl Row {
/// Will copy value at index `index` if it was not taken by `Row::take` earlier,
/// then will convert it to `T`. Returns `None` if the value was taken taken by
/// `Row::take` or was not able to be converted to `T`.
- pub fn get_opt<T, I>(&mut self, index: I) -> Option<T>
+ pub fn get_opt<T, I>(&mut self, index: I) -> Option<MyResult<T>>
where T: FromValue,
I: ColumnIndex {
index.idx(&*self.columns)
.and_then(|idx| self.values.get(idx))
.and_then(|x| x.as_ref())
- .and_then(|x| from_value_opt::<T>(x.clone()).ok())
+ .and_then(|x| Some(from_value_opt::<T>(x.clone())))
}
/// Will take value of a column with index `index` if it exists and wasn't taken earlier then
@@ -684,13 +684,13 @@ impl Row {
/// Will take value of a column with index `index` if it exists and wasn't taken earlier then
/// will converts it to `T`. Returns `None` if the value was taken earlier or was not able
/// to be converted to `T`.
- pub fn take_opt<T, I>(&mut self, index: I) -> Option<T>
+ pub fn take_opt<T, I>(&mut self, index: I) -> Option<MyResult<T>>
where T: FromValue,
I: ColumnIndex {
index.idx(&*self.columns)
.and_then(|idx| self.values.get_mut(idx))
.and_then(|x| x.take())
- .and_then(|x| from_value_opt::<T>(x).ok())
+ .and_then(|x| Some(from_value_opt::<T>(x)))
}
/// Unwraps values of a row.
