Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 815175f

Browse files
committed
Remove expect on utf8
Should always be utf8 in practice, but there's no point in panicking.
1 parent 8a0eab0 commit 815175f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

postgres/src/text_rows.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use postgres_shared::rows::RowData;
44
use std::fmt;
55
use std::slice;
6+
use std::str;
67

78
#[doc(inline)]
89
pub use postgres_shared::rows::RowIndex;
@@ -171,7 +172,7 @@ impl<'a> TextRow<'a> {
171172
None => return None,
172173
};
173174

174-
// TODO can we assume these values will always be utf8?
175-
Some(self.data.get(idx).map(|s| ::std::str::from_utf8(s).expect("utf8 encoded")))
175+
self.data.get(idx)
176+
.map(|s| str::from_utf8(s).ok())
176177
}
177178
}

0 commit comments

Comments
 (0)