File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1606,7 +1606,8 @@ impl<R: io::Read> Reader<R> {
1606
1606
}
1607
1607
return result;
1608
1608
}
1609
- } else if self . state . trim . should_trim_fields ( ) {
1609
+ }
1610
+ if self . state . trim . should_trim_fields ( ) {
1610
1611
record. trim ( ) ;
1611
1612
}
1612
1613
Ok ( ok)
@@ -2302,6 +2303,20 @@ mod tests {
2302
2303
}
2303
2304
}
2304
2305
2306
+ #[ test]
2307
+ fn read_trimmed_records_without_headers ( ) {
2308
+ let data = b ( "a1, b1\t ,\t c1\t \n " ) ;
2309
+ let mut rdr = ReaderBuilder :: new ( )
2310
+ . has_headers ( false )
2311
+ . trim ( Trim :: All )
2312
+ . from_reader ( data) ;
2313
+ let mut rec = ByteRecord :: new ( ) ;
2314
+ assert ! ( rdr. read_byte_record( & mut rec) . unwrap( ) ) ;
2315
+ assert_eq ! ( "a1" , s( & rec[ 0 ] ) ) ;
2316
+ assert_eq ! ( "b1" , s( & rec[ 1 ] ) ) ;
2317
+ assert_eq ! ( "c1" , s( & rec[ 2 ] ) ) ;
2318
+ }
2319
+
2305
2320
#[ test]
2306
2321
fn read_record_unequal_fails ( ) {
2307
2322
let data = b ( "foo\n bar,baz" ) ;
You can’t perform that action at this time.
0 commit comments