Make build work (#546)

The mbedtls example has caused problem in the main build a number of
times. By making it a standalone `cargo new --bin`, we can keep it in
the source tree as a good example but avoid having it break the main
build.

Also, fix some clippy lints.
This commit is contained in:
Martin Algesten
2022-09-29 17:29:32 +02:00
committed by GitHub
parent a367a82317
commit b0796c18f3
12 changed files with 27 additions and 11 deletions

View File

@@ -0,0 +1,8 @@
[package]
name = "mbedtls-example"
version = "0.0.1"
edition = "2021"
[dependencies]
mbedtls = { version = "0.8.1" }

View File

@@ -0,0 +1,9 @@
mbedtls-example
===============
To run this example you need to `cd` into the directory and use `cargo run`.
```
cd ureq/exampled/mbedtls
cargo run
```

View File

@@ -5,7 +5,6 @@ use std::time::Duration;
use std::{env, error, fmt, result};
use log::{error, info};
use ureq;
#[derive(Debug)]
struct Oops(String);
@@ -77,7 +76,7 @@ fn get_many(urls: Vec<String>, simultaneous_fetches: usize) -> Result<()> {
}
fn main() -> Result<()> {
let args = env::args();
let mut args = env::args();
if args.len() == 1 {
println!(
r##"Usage: {:#?} top-1m.csv
@@ -94,11 +93,11 @@ using 50 threads concurrently.
return Ok(());
}
env_logger::init();
let file = std::fs::File::open(args.skip(1).next().unwrap())?;
let file = std::fs::File::open(args.nth(1).unwrap())?;
let bufreader = BufReader::new(file);
let mut urls = vec![];
for line in bufreader.lines() {
let domain = line?.rsplit(",").next().unwrap().to_string();
let domain = line?.rsplit(',').next().unwrap().to_string();
urls.push(format!("http://{}/", domain));
urls.push(format!("https://{}/", domain));
urls.push(format!("http://www.{}/", domain));