Closed lucatrv closed 4 months ago
Sure!
Why not directly something like from_range_with_header<T>
?
Why not directly something like
from_range_with_header<T>
?
I though it would be better to keep aligned with RangeDeserializerBuilder::with_headers
and possible other future methods RangeDeserializerBuilder::with_columns
and Range::rows_with_columns
, as discussed with feature request #314. They all specify the elements to keep, while the range is specified elsewhere.
However I'm also good with from_range_with_headers::<T>(&range)
if you prefer it, but then maybe there could also be a from_range_with_headers_slice(&range, &headers)
.
Another option to consider would be to deprecate the current RangeDeserializerBuilder::with_headers
, and keep only RangeDeserializerBuilder::from_range
, RangeDeserializerBuilder::from_range_with_headers
, and RangeDeserializerBuilder::from_range_with_columns
.
Please let me know your preference.
After thinking a little bit more about this, IMHO the best choice is RangeDeserializerBuilder::with_deserialize_headers
.
Often we need to write something like:
However, for structs which derive
Deserialize
, it is possible to get the Serde field names from the struct type, see for instance theserde_aux::serde_introspection
andrust_xlsxwriter::deserialize_headers
implementations.It would be very convenient to add a
RangeDeserializerBuilder::with_headers_struct
(or other name) in order to write:@tafia if you agree I can implement this and issue a PR.