我想hyper::Client
根据 URL 方案进行配置。为此,我创建了一个小方法:
extern crate http; // 0.1.8
extern crate hyper; // 0.12.7
extern crate hyper_tls; // 0.1.4
use http::uri::Scheme;
use hyper::{Body, Client, Uri};
use hyper_tls::HttpsConnector;
#[derive(Clone, Debug)]
pub struct Feed;
impl Feed {
fn get_client(uri: Uri) -> Client {
match uri.scheme_part() {
Some(Scheme::HTTP) => Client::new(),
Some(Scheme::HTTPS) => {
let https = HttpsConnector::new(4).expect("TLS initialization failed");
let client = Client::builder().build::<_, Body>(https);
}
_ => panic!("We don't support schemes other than HTTP/HTTPS"),
}
}
}
当我尝试编译它时,我收到以下错误消息:
error[E0243]: wrong number of type arguments: expected at least 1, found 0
--> src/main.rs:13:32
|
13 | fn get_client(uri: Uri) -> Client {
| ^^^^^^ expected at least 1 type argument
我不明白为什么它不能编译
- 我已经在 main.rs 中声明了我对超级板条箱的使用
- 我在文件头中声明我的用途
我究竟做错了什么 ?