samscott89 / serde_qs

Serde support for querystring-style strings
Apache License 2.0
193 stars 68 forks source link

Fix empty output in csv_vectors example #89

Closed neilyio closed 7 months ago

neilyio commented 1 year ago

I found that cargo run --example csv_vectors produced incorrect output:

Query { r: [], s: 12 }

Where, based on the example, I expected:

Query { r: [1, 2, 3], s: 12 }

I believe the csv::Reader::from_reader function expects data where each line is a record. However, in the example, all values are on a single line, so the CSV reader treats them as columns of a single record.

I adjusted the from_csv function's trait bounds to ensure that T can be both deserialized and converted from a string. I also revamped the CSV parsing using ReaderBuilder for a bit more flexibility.

This new implementation produces the expected output.

samscott89 commented 7 months ago

Thank you!