Lurker News

Comments (114) 25 threads

Show all comments

Showing thread 5 of 25

halestock1 reply#
Are dynamic params enforced at compile time? I.e. will the compiler ensure that the route "/" has a matching id parameter?
sbenitez2 replies#
Yes! Here's what happens when you don't do the right thing:

  error: 'id' is declared as an argument...
   --> src/main.rs:8:9
    |
  8 | #[get("/")]
    |         ^^^^

  error: ...but isn't in the function signature.
    --> src/main.rs:9:1
     |
  9  |   fn hello() -> &'static str {
     |  _^ starting here...
  10 | |     "Hello, world!"
  11 | | }
     | |_^ ...ending here
jtmarmon#
that is some truly incredible developer ux
chrismorgan#
The span for the “...but isn't in the function signature” should be just the `()` rather than the whole function.