Skip to content

Instantly share code, notes, and snippets.

@gyscos
Last active August 29, 2015 14:20
Show Gist options
  • Save gyscos/92e56e95baee0ebce78f to your computer and use it in GitHub Desktop.
Save gyscos/92e56e95baee0ebce78f to your computer and use it in GitHub Desktop.
Failed example of accessible immutable ref from Iron
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