Use CStr::to_str where possible

This commit is contained in:
gwenn
2024-03-10 11:53:29 +01:00
parent 6036587952
commit 87e324d720
7 changed files with 19 additions and 25 deletions

View File

@@ -441,7 +441,8 @@ impl Statement<'_> {
#[inline]
pub fn parameter_name(&self, index: usize) -> Option<&'_ str> {
self.stmt.bind_parameter_name(index as i32).map(|name| {
str::from_utf8(name.to_bytes()).expect("Invalid UTF-8 sequence in parameter name")
name.to_str()
.expect("Invalid UTF-8 sequence in parameter name")
})
}
@@ -766,7 +767,7 @@ impl fmt::Debug for Statement<'_> {
let sql = if self.stmt.is_null() {
Ok("")
} else {
str::from_utf8(self.stmt.sql().unwrap().to_bytes())
self.stmt.sql().unwrap().to_str()
};
f.debug_struct("Statement")
.field("conn", self.conn)