File tree 1 file changed +8
-7
lines changed
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,15 @@ struct SIMDExample<'sin> {
15
15
16
16
fn main ( ) {
17
17
let data_file = File :: open ( "/home/aj/deploy/rust/zcapjson/data/fake_data.json" ) . unwrap ( ) ;
18
- let reader = BufReader :: new ( data_file) ;
18
+ let mut reader = BufReader :: new ( data_file) ;
19
19
20
- for line in reader . lines ( ) {
21
- let row : & mut str = & mut line . unwrap ( ) ;
22
- let row : SIMDExample = serde_json :: from_str ( row ) . unwrap ( ) ;
23
- match row. id {
24
- 2807149942735425369 => println ! ( "look ma! a match! - {}" , row . id_str ) ,
25
- _ => println ! ( "No match yet" ) ,
20
+ let mut data = Vec :: with_capacity ( 1024 ) ;
21
+
22
+ while reader . read_until ( b'\n' , & mut data ) . unwrap ( ) > 0 {
23
+ let row: SIMDExample = serde_json :: from_slice ( data . as_mut_slice ( ) ) . unwrap ( ) ;
24
+ if row . id == 2807149942735425369 {
25
+ println ! ( "look ma! a match! - {}" , row . id_str ) ;
26
26
}
27
+ data. clear ( ) ;
27
28
}
28
29
}
You can’t perform that action at this time.
0 commit comments