Skip to content

Instantly share code, notes, and snippets.

@tbillington
Created August 19, 2015 06:19
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 tbillington/cd207c8d95de20c78b28 to your computer and use it in GitHub Desktop.
Save tbillington/cd207c8d95de20c78b28 to your computer and use it in GitHub Desktop.
rust error
extern crate iron;
extern crate router;
use iron::{BeforeMiddleware, AfterMiddleware, typemap, Iron, Request, Response, IronResult};
use router::{Router};
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((iron::status::Ok, "Hello World\n")))
}
fn main() {
let mut router = Router::new();
router.get("/", hello_world);
Iron::new(router).http("localhost:3000").unwrap();
}
// ---------- Errors ----------
$ cargo build
Compiling hello_world v0.1.0 (file:///home/trent/prog/rust/hello_world)
src/main.rs:42:12: 42:33 error: type mismatch: the type `fn(&mut iron::request::Request<'_, '_>) -> core::result::Result<iron::response::Response, iron::error::IronError> {hello_world}` implements the trait `for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is required (expected struct `iron::request::Request`, found a different struct `iron::request::Request`) [E0281]
src/main.rs:42 router.get("/", hello_world);
^~~~~~~~~~~~~~~~~~~~~
src/main.rs:42:12: 42:33 error: type mismatch: the type `fn(&mut iron::request::Request<'_, '_>) -> core::result::Result<iron::response::Response, iron::error::IronError> {hello_world}` implements the trait `for<'r, 'r, 'r> core::ops::FnOnce<(&'r mut iron::request::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> core::ops::FnOnce<(&'r mut iron::request::Request<'r, 'r>,)>` is required (expected struct `iron::request::Request`, found a different struct `iron::request::Request`) [E0281]
src/main.rs:42 router.get("/", hello_world);
^~~~~~~~~~~~~~~~~~~~~
src/main.rs:43:23: 43:45 error: no method named `http` found for type `iron::iron::Iron<router::router::Router>` in the current scope
src/main.rs:43 Iron::new(router).http("localhost:3000").unwrap();
^~~~~~~~~~~~~~~~~~~~~~
src/main.rs:43:23: 43:45 note: the method `http` exists but the following trait bounds were not satisfied: `router::router::Router : iron::middleware::Handler`
src/main.rs:43:5: 43:14 error: the trait `for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is not implemented for the type `router::router::Router` [E0277]
src/main.rs:43 Iron::new(router).http("localhost:3000").unwrap();
^~~~~~~~~
src/main.rs:43:5: 43:14 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:43:5: 43:14 note: required by `iron::iron::Iron<H>::new`
src/main.rs:43 Iron::new(router).http("localhost:3000").unwrap();
^~~~~~~~~
src/main.rs:43:5: 43:14 error: the trait `for<'r, 'r, 'r> core::ops::FnOnce<(&'r mut iron::request::Request<'r, 'r>,)>` is not implemented for the type `router::router::Router` [E0277]
src/main.rs:43 Iron::new(router).http("localhost:3000").unwrap();
^~~~~~~~~
src/main.rs:43:5: 43:14 help: run `rustc --explain E0277` to see a detailed explanation
src/main.rs:43:5: 43:14 note: required by `iron::iron::Iron<H>::new`
src/main.rs:43 Iron::new(router).http("localhost:3000").unwrap();
^~~~~~~~~
error: aborting due to 5 previous errors
Could not compile `hello_world`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment