Created
May 21, 2020 09:16
-
-
Save LnL7/85fcb8c97bb0deb97f89e1807b3b3686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0277]: the size for values of type `dyn std::error::Error + std::marker::Send + std::marker::Sync` cannot be known at compilation time | |
--> src/main.rs:9:78 | |
| | |
67 | .map_err(|err| tide::Error::new(StatusCode::InternalServerError, err))?; | |
| ^^^ doesn't have a size known at compile-time | |
| | |
= help: the trait `std::marker::Sized` is not implemented for `dyn std::error::Error + std::marker::Send + std::marker::Sync` | |
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> | |
= note: required because of the requirements on the impl of `std::error::Error` for `std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>` | |
error: aborting due to 2 previous errors | |
Some errors have detailed explanations: E0277, E0425. | |
For more information about an error, try `rustc --explain E0277`. | |
error: could not compile `example`. | |
To learn more, run the command again with --verbose. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tide::{Body, Request, Response}; | |
use tide::http::StatusCode; | |
fn main() { | |
let mut app = tide::new(); | |
app.at("/").get(|mut _req: Request<()>| async { | |
let _: String = surf::get("http://example.org").recv_json().await | |
.map_err(|err| tide::Error::new(StatusCode::InternalServerError, err))?; | |
// other stuff... | |
let resp = Response::new(StatusCode::Ok); | |
Ok(resp) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment