Skip to content

Instantly share code, notes, and snippets.

@euank
Last active November 28, 2016 00:53
Show Gist options
  • Select an option

  • Save euank/26482786d5a7b65d71c1ca177b8a36a5 to your computer and use it in GitHub Desktop.

Select an option

Save euank/26482786d5a7b65d71c1ca177b8a36a5 to your computer and use it in GitHub Desktop.
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter};
use std::collections::HashMap;
fn main() {
let mut server = Nickel::new();
// * NOTE *
// This example is deprecated, you should use nickel_mustache from crates.io
server.get("/", middleware! { |_, res|
let mut data = HashMap::<&str, &str>::new();
data.insert("name", "user");
return res.render("examples/assets/template.tpl", &data)
});
server.listen("127.0.0.1:6767").unwrap();
}
// Build output
/* Compiling synapse-password-reset v0.1.0 (file:///home/esk/dev/synapse-password-reset)
warning: unreachable expression, #[warn(unreachable_code)] on by default
--> src/main.rs:12:21
|
12 | server.get("/", middleware! { |_, res|
| ^
|
= note: this error originates in a macro outside of the current crate
Finished debug [unoptimized + debuginfo] target(s) in 4.46 secs
*/
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter};
use std::collections::HashMap;
fn main() {
let mut server = Nickel::new();
// * NOTE *
// This example is deprecated, you should use nickel_mustache from crates.io
server.get("/", middleware! { |_, res|
let mut data = HashMap::<&str, &str>::new();
data.insert("name", "user");
res.render("examples/assets/template.tpl", &data)
});
server.listen("127.0.0.1:6767").unwrap();
}
// build output
/* Compiling synapse-password-reset v0.1.0 (file:///home/esk/dev/synapse-password-reset)
error[E0277]: the trait bound `nickel::Action<nickel::Response<'_, _>, nickel::Response<'_, _, hyper::net::Streaming>>: nickel::Responder<_>` is not satisfied
--> src/main.rs:12:21
|
12 | server.get("/", middleware! { |_, res|
| ^ the trait `nickel::Responder<_>` is not implemented for `nickel::Action<nickel::Response<'_, _>, nickel::Response<'_, _, hyper::net::Streaming>>`
|
= note: required because of the requirements on the impl of `nickel::Responder<_>` for `std::result::Result<nickel::Action<nickel::Response<'_, _>, nickel::Response<'_, _, hyper::net::Streaming>>, nickel::NickelError<'_, _>>`
= note: required by `main::restrict`
= note: this error originates in a macro outside of the current crate
error[E0277]: the trait bound `for<'e> nickel::NickelError<'e, _>: std::convert::From<(nickel::Response<'e, _>, nickel::NickelError<'_, _>)>` is not satisfied
--> src/main.rs:12:21
|
12 | server.get("/", middleware! { |_, res|
| ^ the trait `for<'e> std::convert::From<(nickel::Response<'e, _>, nickel::NickelError<'_, _>)>` is not implemented for `nickel::NickelError<'e, _>`
|
= help: the following implementations were found:
= help: <nickel::NickelError<'a, D> as std::convert::From<(nickel::Response<'a, D>, (nickel::status::StatusCode, T))>>
= help: <nickel::NickelError<'a, D> as std::convert::From<(nickel::Response<'a, D>, std::string::String)>>
= help: <nickel::NickelError<'a, D> as std::convert::From<(nickel::Response<'a, D>, nickel::status::StatusCode)>>
= note: required because of the requirements on the impl of `nickel::Responder<_>` for `std::result::Result<nickel::Action<nickel::Response<'_, _>, nickel::Response<'_, _, hyper::net::Streaming>>, nickel::NickelError<'_, _>>`
= note: required by `main::restrict`
= note: this error originates in a macro outside of the current crate
error: aborting due to 2 previous errors
error: Could not compile `synapse-password-reset`.
To learn more, run the command again with --verbose.
*/
@euank

euank commented Nov 28, 2016

Copy link
Copy Markdown
Author

Example of how macros make things confusing.

Sourced from https://github.com/nickel-org/nickel.rs/blob/master/examples/template.rs

The implicit return is missing from the second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment