Skip to content

Instantly share code, notes, and snippets.

@LnL7
Created May 21, 2020 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LnL7/85fcb8c97bb0deb97f89e1807b3b3686 to your computer and use it in GitHub Desktop.
Save LnL7/85fcb8c97bb0deb97f89e1807b3b3686 to your computer and use it in GitHub Desktop.
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.
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