考虑以下代码:
extern crate nickel;
use nickel::{Nickel, HttpRouter, Request, Response, MiddlewareResult};
fn main() {
let data = "wanted";
let mut server = Nickel::new();
server.get("/", landing);
server.listen("localhost:6767");
}
fn landing<'a>(_: &mut Request, response: Response<'a>) -> MiddlewareResult<'a> {
response.send("not wanted")
}
我想data
在函数中使用landing
。