File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -118,16 +118,11 @@ mod kv {
118
118
/// as_kv(example) // returns [KV {key: "filename", value: "don't test me"}]
119
119
/// ```
120
120
pub fn as_kv ( input : & str ) -> Result < KV , nom:: ErrorKind > {
121
- let parts: Vec < _ > = input. split ( ": " ) . collect ( ) ;
122
- let result = KV {
123
- key : parts [ 0 ] . trim ( ) . to_string ( ) ,
124
- value : parts [ 1 .. ] . join ( "" ) . to_string ( ) ,
121
+ let parts: Vec < _ > = if input. contains ( ":" ) {
122
+ input . split ( ": " ) . collect ( )
123
+ } else {
124
+ input . split_whitespace ( ) . collect ( )
125
125
} ;
126
- Ok ( result)
127
- }
128
-
129
- pub fn as_kv_whitespace ( input : & str ) -> Result < KV , nom:: ErrorKind > {
130
- let parts: Vec < _ > = input. split_whitespace ( ) . collect ( ) ;
131
126
let result = KV {
132
127
key : parts[ 0 ] . trim ( ) . to_string ( ) ,
133
128
value : parts[ 1 ..] . join ( " " ) . to_string ( ) ,
@@ -179,7 +174,7 @@ mod doc {
179
174
take_until_and_consume!( delims. opt) ,
180
175
take_until_and_consume!( "\n " )
181
176
) ,
182
- as_kv_whitespace
177
+ as_kv
183
178
) ) ) )
184
179
>> par: opt!( many0!( complete!( map_res!(
185
180
preceded!(
You can’t perform that action at this time.
0 commit comments