Advertisement
Guest User

rust webdev--please help!

a guest
Feb 26th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 3.55 KB | None | 0 0
  1. extern crate iron;
  2. extern crate router;
  3.  
  4. use iron::prelude::*;
  5. use iron::status;
  6. use router::Router;
  7.  
  8. fn main() {
  9.     let mut router = Router::new();
  10.  
  11.     router.get("/", hello_world, "index");
  12.  
  13.     fn hello_world(_: &mut Request) -> IronResult<Response> {
  14.         Ok(Response::with((status::Ok, "Hello World!")))
  15.     }
  16.  
  17.     Iron::new(router).http("localhost:3000").unwrap();
  18.     println!("On 3000");
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.    Compiling emmaramirez_me v0.0.1 (file:///C:/Users/Emma%20Ramirez/Code/emmaramirez.me)
  27. src\main.rs:11:12: 11:15 error: type mismatch: the type `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::hello_world}` implements the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is required (expected struct `iron::request::Request`, found struct `iron::Request`) [E0281]
  28. src\main.rs:11     router.get("/", hello_world, "index");
  29.                           ^~~
  30. src\main.rs:11:12: 11:15 help: run `rustc --explain E0281` to see a detailed explanation
  31. src\main.rs:11:12: 11:15 note: required because of the requirements on the impl of `iron::middleware::Handler` for `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::hello_world}`
  32. src\main.rs:11:12: 11:15 error: type mismatch: the type `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::hello_world}` implements the trait `for<'r, 'r, 'r> std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> std::ops::FnOnce<(&'r mut iron::request::Request<'r, 'r>,)>` is required (expected struct `iron::request::Request`, found struct `iron::Request`) [E0281]
  33. src\main.rs:11     router.get("/", hello_world, "index");
  34.                           ^~~
  35. src\main.rs:11:12: 11:15 help: run `rustc --explain E0281` to see a detailed explanation
  36. src\main.rs:11:12: 11:15 note: required because of the requirements on the impl of `iron::middleware::Handler` for `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::hello_world}`
  37. src\main.rs:17:5: 17:14 error: the trait bound `for<'r, 'r, 'r> router::Router: std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied [E0277]
  38. src\main.rs:17     Iron::new(router).http("localhost:3000").unwrap();
  39.                    ^~~~~~~~~
  40. src\main.rs:17:5: 17:14 help: run `rustc --explain E0277` to see a detailed explanation
  41. src\main.rs:17:5: 17:14 note: required because of the requirements on the impl of `iron::Handler` for `router::Router`
  42. src\main.rs:17:5: 17:14 note: required by `iron::Iron::new`
  43. src\main.rs:17:5: 17:14 error: the trait bound `for<'r, 'r, 'r> router::Router: std::ops::FnOnce<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied [E0277]
  44. src\main.rs:17     Iron::new(router).http("localhost:3000").unwrap();
  45.                    ^~~~~~~~~
  46. src\main.rs:17:5: 17:14 help: run `rustc --explain E0277` to see a detailed explanation
  47. src\main.rs:17:5: 17:14 note: required because of the requirements on the impl of `iron::Handler` for `router::Router`
  48. src\main.rs:17:5: 17:14 note: required by `iron::Iron::new`
  49. src\main.rs:17:23: 17:27 error: no method named `http` found for type `iron::Iron<router::Router>` in the current scope
  50. src\main.rs:17     Iron::new(router).http("localhost:3000").unwrap();
  51.                                      ^~~~
  52. src\main.rs:17:23: 17:27 note: the method `http` exists but the following trait bounds were not satisfied: `router::Router : iron::Handler`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement