i clone Paul Woolcock / soup · GitLab and run example file,every thing is ok,but when i create a project,but when i created a same file as the example file,i encountered some strange error.:
the code is
use std::collections::HashSet;
use std::fmt::Error;
use soup::Soup;
use reqwest;
fn main() -> Result<(), Box> {
let resp = reqwest::get("xxx")?;
let soup = Soup::from_reader(resp)?;
let result = soup
.tag("section")
.attr("id", "main")
.find()
.and_then(|section| {
section
.tag("span")
.attr("class", "in-band")
.find()
.map(|span| span.text())
});
assert_eq!(result, Some("Crate soup".to_string()));
Ok(())
}
cargo file
[package]
name = "testquestion"
version = "0.1.0"
authors = ["wangyiran"]
edition = "2018"
[dependencies]
soup = "0.3"
reqwest = { version = "0.10.0-alpha.2", features = ["blocking"] }
What did I miss? Please give me some suggestions,thanks so much!
error[E0277]: the
?
operator can only be applied to values that implementstd::ops::Try
error[E0277]: the?
operator can only be applied to values that implementstd::ops::Try
--> src\main.rs:6:16
|
6 | let resp = reqwest::get("xxx")?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the?
operator cannot be applied to typeimpl std::future::Future
|
= help: the traitstd::ops::Try
is not implemented forimpl std::future::Future
= note: required bystd::ops::Try::into_result
error[E0277]:
?
couldn't convert the error tostd::boxed::Box<std::fmt::Error>
--> src\main.rs:7:39
|
7 | let soup = Soup::from_reader(resp)?;
| ^ the traitstd::convert::From<std::io::Error>
is not implemented forstd::boxed::Box<std::fmt::Error>
|
= note: the question mark operation (?
) implicitly performs a conversion on the error value using theFrom
trait
= help: the following implementations were found:
<std::boxed::Box<(dyn std::error::Error + 'a)> as std::convert::From>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<&str>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::borrow::Cow<'a, str>>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::Fromstd::string::String>
and 16 others
= note: required bystd::convert::From::from
error[E0599]: no method named
tag
found for typestd::rc::Rc<markup5ever::rcdom::Node>
in the current scope
--> src\main.rs:14:18
|
14 | .tag("span")
| ^^^ method not found instd::rc::Rc<markup5ever::rcdom::Node>
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add ause
for it:
|
1 | use soup::handle_ext::HandleExt;
|error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0599.
For more information about an error, tryrustc --explain E0277
.
error: could not compiletestquestion
.