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> {
16061606 }
16071607 return result;
16081608 }
1609- } else if self . state . trim . should_trim_fields ( ) {
1609+ }
1610+ if self . state . trim . should_trim_fields ( ) {
16101611 record. trim ( ) ;
16111612 }
16121613 Ok ( ok)
@@ -2302,6 +2303,20 @@ mod tests {
23022303 }
23032304 }
23042305
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+
23052320 #[ test]
23062321 fn read_record_unequal_fails ( ) {
23072322 let data = b ( "foo\n bar,baz" ) ;
You can’t perform that action at this time.
0 commit comments