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 {
118118 /// as_kv(example) // returns [KV {key: "filename", value: "don't test me"}]
119119 /// ```
120120 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 ( )
125125 } ;
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 ( ) ;
131126 let result = KV {
132127 key : parts[ 0 ] . trim ( ) . to_string ( ) ,
133128 value : parts[ 1 ..] . join ( " " ) . to_string ( ) ,
@@ -179,7 +174,7 @@ mod doc {
179174 take_until_and_consume!( delims. opt) ,
180175 take_until_and_consume!( "\n " )
181176 ) ,
182- as_kv_whitespace
177+ as_kv
183178 ) ) ) )
184179 >> par: opt!( many0!( complete!( map_res!(
185180 preceded!(
You can’t perform that action at this time.
0 commit comments