Provide more details for opaque examples in guide.

Closes #1100.
This commit is contained in:
Sergio Benitez 2020-02-15 19:47:50 -08:00
parent 95c981de79
commit 39b1f2f8d0
4 changed files with 12 additions and 10 deletions

View File

@ -735,20 +735,15 @@ use rocket::request::FlashMessage;
#[get("/")]
fn bad(cookies: Cookies, flash: FlashMessage) {
// Oh no! `flash` holds a reference to `Cookies` too!
let msg = flash.msg();
}
```
```rust
# #[macro_use] extern crate rocket;
# fn main() {}
# use rocket::http::Cookies;
# use rocket::request::FlashMessage;
#[get("/")]
fn good(cookies: Cookies, flash: FlashMessage) {
std::mem::drop(cookies);
// Now, `flash` holds an _exclusive_ reference to `Cookies`. Whew.
let msg = flash.msg();
}
```

View File

@ -399,7 +399,7 @@ fairings. To attach the template fairing, simply call
fn main() {
rocket::ignite()
.mount("/", routes![ /* .. */])
.mount("/", routes![/* .. */])
.attach(Template::fairing());
}
```

View File

@ -331,6 +331,13 @@ fn get_logs(conn: LogsDbConn, id: usize) -> Logs {
}
```
! note The above examples uses [Diesel] with some fictional `Logs` type.
The example above contains the use of a `Logs` type that is application
specific and not built into Rocket. It also uses [Diesel]'s query-building
syntax. Rocket does not provide an ORM. It is up to you to decide how to model
your application's data.
If your application uses features of a database engine that are not available
by default, for example support for `chrono` or `uuid`, you may enable those
features by adding them in `Cargo.toml` like so:

View File

@ -205,7 +205,7 @@ We do this by checking the `Response` object directly:
# use rocket::local::Client;
use rocket::http::{ContentType, Status};
#
# let rocket = rocket::ignite().mount("/", routes![hello]);
# let client = Client::new(rocket).expect("valid rocket instance");
# let mut response = client.get("/").dispatch();