1+ //! Curl compatibility utilities
12use std:: str:: FromStr ;
23
3- ///! Curl compatibility utilities
4-
54pub struct Form {
65 pub boundary : String ,
76 pub parts : Vec < FormPart > ,
@@ -83,10 +82,10 @@ impl Form {
8382 // Convert to hex string manually to avoid external hex dependency
8483 let hex_string = random_bytes
8584 . iter ( )
86- . map ( |b| format ! ( "{:02x}" , b ) )
85+ . map ( |b| format ! ( "{b :02x}" ) )
8786 . collect :: < String > ( ) ;
8887
89- format ! ( "----formdata-oha-{}" , hex_string )
88+ format ! ( "----formdata-oha-{hex_string}" )
9089 }
9190}
9291
@@ -117,8 +116,8 @@ impl FromStr for FormPart {
117116 let data;
118117
119118 // Check if this is a file upload (@filename or <filename)
120- if value_part. starts_with ( '@' ) {
121- let file_path = & value_part [ 1 .. ] ; // Remove '@' prefix
119+ if let Some ( file_path ) = value_part. strip_prefix ( '@' ) {
120+ // Remove '@' prefix
122121
123122 // Read file content
124123 data = std:: fs:: read ( file_path)
@@ -129,8 +128,8 @@ impl FromStr for FormPart {
129128 . file_name ( )
130129 . and_then ( |name| name. to_str ( ) )
131130 . map ( |s| s. to_string ( ) ) ;
132- } else if value_part. starts_with ( '<' ) {
133- let file_path = & value_part [ 1 .. ] ; // Remove '<' prefix
131+ } else if let Some ( file_path ) = value_part. strip_prefix ( '<' ) {
132+ // Remove '<' prefix
134133
135134 // Read file content
136135 data = std:: fs:: read ( file_path)
0 commit comments