Skip to content

Commit

Permalink
fix: do not swallow errors in (get|take)_opt methods
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharygolba committed Jun 30, 2017
1 parent 7c647ab commit 9be65b6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 9be65b6

Please sign in to comment.