Last active
August 29, 2015 14:20
-
-
Save gyscos/92e56e95baee0ebce78f to your computer and use it in GitHub Desktop.
Failed example of accessible immutable ref from Iron
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
extern crate iron; | |
use iron::prelude::*; | |
use iron::status; | |
struct MyObject; | |
impl MyObject { | |
fn foo(&self) {} | |
} | |
fn serve(obj: &MyObject) { | |
// For simplicity, we're going for a VERY minimal approach here, | |
// without any route or anything... | |
Iron::new(|_: &mut Request| { | |
obj.foo(); | |
Ok(Response::with((status::Ok, "Hello world!"))) | |
}).http("localhost:3000").unwrap(); | |
} | |
fn main() { | |
let obj: MyObject; | |
serve(&obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment