From 815175ffd89d1d87cb5fe4f5a3a9cb2a7bd4c9e2 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Fri, 27 Apr 2018 17:00:37 -0700 Subject: [PATCH] Remove expect on utf8 Should always be utf8 in practice, but there's no point in panicking. --- postgres/src/text_rows.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/postgres/src/text_rows.rs b/postgres/src/text_rows.rs index a2c2bfd6..208c2a0f 100644 --- a/postgres/src/text_rows.rs +++ b/postgres/src/text_rows.rs @@ -3,6 +3,7 @@ use postgres_shared::rows::RowData; use std::fmt; use std::slice; +use std::str; #[doc(inline)] pub use postgres_shared::rows::RowIndex; @@ -171,7 +172,7 @@ impl<'a> TextRow<'a> { None => return None, }; - // TODO can we assume these values will always be utf8? - Some(self.data.get(idx).map(|s| ::std::str::from_utf8(s).expect("utf8 encoded"))) + self.data.get(idx) + .map(|s| str::from_utf8(s).ok()) } }