learning the difference between String and &str

This commit is contained in:
crunk 2023-11-04 11:30:55 +01:00
parent 1cc4ca8661
commit 78594af0ac

View File

@ -21,7 +21,7 @@ struct Cli {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::parse(); let args = Cli::parse();
let url = args.url; let url = args.url.as_str();
let text = args.text; let text = args.text;
if text.is_some() { if text.is_some() {
let client = reqwest::blocking::Client::new(); let client = reqwest::blocking::Client::new();
@ -33,7 +33,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::blocking::Client::new(); let client = reqwest::blocking::Client::new();
let form = multipart::Form::new().file("file", &file_name)?; let form = multipart::Form::new().file("file", &file_name)?;
let res = client.post("your url").multipart(form).send()?; let res = client.post(url).multipart(form).send()?;
println!("{:?}", res) println!("{:?}", res)
} }
Ok(()) Ok(())