From b5b575553e7bd7468f21f9188b8036532eb5b120 Mon Sep 17 00:00:00 2001 From: Bart Massey Date: Mon, 7 Jun 2021 02:05:49 -0700 Subject: [PATCH] fixed dorothea example to compile as test --- Cargo.toml | 5 ++++- examples/dorothea.rs | 18 +++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 82bc5ca..49fe258 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,10 +29,13 @@ cc = "1.0" [dev-dependencies] bincode = "1.0" csv = "0.14" -hyper = "0.7.0" serde_json = "1.0" time = "0.1" +[dev-dependencies.reqwest] +version = "0.11.3" +features = ["blocking"] + [features] all_tests = [] bench = [] diff --git a/examples/dorothea.rs b/examples/dorothea.rs index 2f30e89..e4905da 100644 --- a/examples/dorothea.rs +++ b/examples/dorothea.rs @@ -11,7 +11,7 @@ use std::io::{Read, Write}; use std::path::Path; use std::fs::File; -extern crate hyper; +extern crate reqwest; extern crate rustlearn; @@ -21,22 +21,10 @@ use rustlearn::trees::decision_tree; use rustlearn::ensemble::random_forest; use rustlearn::metrics; -use hyper::client::Client; - - -fn download_data(url: &str) -> Result { - - let client = Client::new(); - - let mut output = String::new(); - - let mut response = try!(client.get(url).send()); - try!(response.read_to_string(&mut output)); - - Ok(output) +fn download_data(url: &str) -> reqwest::Result { + reqwest::blocking::get(url)?.text() } - fn get_raw_data(url: &str, filename: &str) -> String { let path = Path::new(filename);