From 5c71314983f4a946513027be2a1fc907bd846740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Tue, 7 May 2024 08:26:42 +0200 Subject: [PATCH] serialize: deduplicate do_serialize[_err] --- scylla-cql/src/types/serialize/value.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scylla-cql/src/types/serialize/value.rs b/scylla-cql/src/types/serialize/value.rs index b896b6a528..621ec8f416 100644 --- a/scylla-cql/src/types/serialize/value.rs +++ b/scylla-cql/src/types/serialize/value.rs @@ -1574,17 +1574,21 @@ mod tests { assert_eq!(typed_data, erased_data); } - fn do_serialize(t: T, typ: &ColumnType) -> Vec { + fn do_serialize_result( + t: T, + typ: &ColumnType, + ) -> Result, SerializationError> { let mut ret = Vec::new(); let writer = CellWriter::new(&mut ret); - t.serialize(typ, writer).unwrap(); - ret + t.serialize(typ, writer).map(|_| ()).map(|()| ret) + } + + fn do_serialize(t: T, typ: &ColumnType) -> Vec { + do_serialize_result(t, typ).unwrap() } fn do_serialize_err(t: T, typ: &ColumnType) -> SerializationError { - let mut ret = Vec::new(); - let writer = CellWriter::new(&mut ret); - t.serialize(typ, writer).unwrap_err() + do_serialize_result(t, typ).unwrap_err() } #[test]