Skip to content

Commit 056feb1

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 9b2940c commit 056feb1

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

scylla-rust-wrapper/src/query_result.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ mod tests {
14311431
));
14321432

14331433
let rows = create_cass_rows_from_rows(
1434-
Some(vec![Row {
1434+
vec![Row {
14351435
columns: vec![
14361436
Some(CqlValue::BigInt(42)),
14371437
None,
@@ -1441,11 +1441,14 @@ mod tests {
14411441
CqlValue::Float(9999.9999),
14421442
])),
14431443
],
1444-
}]),
1444+
}],
14451445
&metadata,
14461446
);
14471447

1448-
CassResult { rows, metadata }
1448+
CassResult {
1449+
rows: Some(rows),
1450+
metadata,
1451+
}
14491452
}
14501453

14511454
unsafe fn cass_result_column_name_rust_str(

scylla-rust-wrapper/src/session.rs

+6-5
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,10 +380,9 @@ 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+
) -> Vec<CassRow> {
385386
let cass_rows = rows
386387
.into_iter()
387388
.map(|r| CassRow {
@@ -390,7 +391,7 @@ pub(crate) fn create_cass_rows_from_rows(
390391
})
391392
.collect();
392393

393-
Some(cass_rows)
394+
cass_rows
394395
}
395396

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

0 commit comments

Comments
 (0)