ureq
ureq copied to clipboard
Request::into_string changes error type
This code is currently impossible.
ureq::get(ZONE_URL)
.call()
.and_then(|resp| {
resp.into_string().map(|s| s[0..(s.len() - 1)].to_string())
})
Because .call()
returns a Result<ureq::Response, ureq::Error>
and into_string()
does Result<String, io::Error>
.
mismatched types
expected enum `std::result::Result<_, ureq::Error>`
found enum `std::result::Result<std::string::String, std::io::Error>`
I'm unsure why we used the io
errors on these into_xxx
, maybe just inertia? To fix it would be a breaking change, so maybe park for the future…
It honestly didn't occur to me that we could change it. The main thing going on in into_string()
is reading, which produces io::Error
. But of course, ureq::error::Transport
can hold an io::Error
. Agree on parking for the future.