Skip to content

Commit 538ffaf

Browse files
committed
result: simplify create_cass_rows_from_rows
This function unnecessarily accepted and returned an Option. It should be the caller's responsibility to call this function only if `result.rows` is Some.
1 parent 86ba58d commit 538ffaf

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

scylla-rust-wrapper/src/query_result.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ mod tests {
14331433
));
14341434

14351435
let rows = create_cass_rows_from_rows(
1436-
Some(vec![Row {
1436+
vec![Row {
14371437
columns: vec![
14381438
Some(CqlValue::BigInt(42)),
14391439
None,
@@ -1443,11 +1443,14 @@ mod tests {
14431443
CqlValue::Float(9999.9999),
14441444
])),
14451445
],
1446-
}]),
1446+
}],
14471447
&metadata,
14481448
);
14491449

1450-
CassResult { rows, metadata }
1450+
CassResult {
1451+
rows: Some(rows),
1452+
metadata,
1453+
}
14511454
}
14521455

14531456
unsafe fn cass_result_column_name_rust_str(

scylla-rust-wrapper/src/session.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ pub unsafe extern "C" fn cass_session_execute(
357357
maybe_col_data_types,
358358
result.tracing_id,
359359
));
360-
let cass_rows = create_cass_rows_from_rows(result.rows, &metadata);
360+
let cass_rows = result
361+
.rows
362+
.map(|rows| create_cass_rows_from_rows(rows, &metadata));
361363
let cass_result = Arc::new(CassResult {
362364
rows: cass_rows,
363365
metadata,
@@ -378,19 +380,15 @@ pub unsafe extern "C" fn cass_session_execute(
378380
}
379381

380382
pub(crate) fn create_cass_rows_from_rows(
381-
rows: Option<Vec<Row>>,
383+
rows: Vec<Row>,
382384
metadata: &Arc<CassResultData>,
383-
) -> Option<Vec<CassRow>> {
384-
let rows = rows?;
385-
let cass_rows = rows
386-
.into_iter()
385+
) -> Vec<CassRow> {
386+
rows.into_iter()
387387
.map(|r| CassRow {
388388
columns: create_cass_row_columns(r, metadata),
389389
result_metadata: metadata.clone(),
390390
})
391-
.collect();
392-
393-
Some(cass_rows)
391+
.collect()
394392
}
395393

396394
fn create_cass_row_columns(row: Row, metadata: &Arc<CassResultData>) -> Vec<CassValue> {

0 commit comments

Comments
 (0)