Skip to content

Commit 7dfe827

Browse files
committed
Simplify CStr handling
1 parent da3f6bf commit 7dfe827

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

crates/duckdb/src/raw_statement.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,15 @@ impl RawStatement {
328328
if name_ptr.is_null() {
329329
return Err(Error::DuckDBFailure(
330330
ffi::Error::new(ffi::DuckDBError),
331-
Some(format!("Could not retrieve parameter name for index {}", idx)),
331+
Some(format!("Could not retrieve parameter name for index {idx}")),
332332
));
333333
}
334334

335-
let c_str = CStr::from_ptr(name_ptr);
336-
let result = c_str
337-
.to_str()
338-
.map(|s| s.to_string())
339-
.map_err(|e| Error::FromSqlConversionFailure(0, crate::types::Type::Text, Box::new(e)));
335+
let name = CStr::from_ptr(name_ptr).to_string_lossy().to_string();
340336

341337
ffi::duckdb_free(name_ptr as *mut std::ffi::c_void);
342338

343-
result
339+
Ok(name)
344340
}
345341
}
346342

0 commit comments

Comments
 (0)