相关疑难解决方法(0)

为什么懒惰的静态值声称没有实现它明确实现的特征?

使用以下代码(尝试使用reqwestcrate 发出HTTP请求),编译器说我的值SID_URI没有实现特性PolyfillTryInto.这里发生了什么?reqwest::Url明确地实现了私人特质reqwest::into_url::PolyfillTryInto.

#[macro_use]
extern crate lazy_static;
extern crate reqwest;

static R_EMAIL: &str = "example@example.com";
static R_PASS: &str = "password";
static API_PUBKEY: &str = "99754106633f94d350db34d548d6091a";
static API_URI: &str = "https://example.com";
static AUTH_PATH: &str = "/api/v1";

lazy_static! {
    static ref SID_URI: reqwest::Url = reqwest::Url::parse(&(API_URI.to_owned() + AUTH_PATH)).unwrap();
}

fn get_sid() -> Result<reqwest::Response, reqwest::Error> {
    let client = reqwest::Client::new();
    let params = [("ID", R_EMAIL), ("PW", R_PASS), ("KY", API_PUBKEY)];
    let q = client.post(SID_URI).form(&params).send()?;
    Ok(q)
} …
Run Code Online (Sandbox Code Playgroud)

rust reqwest

5
推荐指数
1
解决办法
855
查看次数

标签 统计

reqwest ×1

rust ×1