Use '&*' in database docs for reliable deref coercions.

Resolves #855.
This commit is contained in:
Sergio Benitez 2018-12-10 22:20:28 -08:00
parent ba96de314c
commit 746023fe1f
2 changed files with 6 additions and 12 deletions

View File

@ -91,7 +91,7 @@
//! #[get("/logs/<id>")] //! #[get("/logs/<id>")]
//! fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> { //! fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> {
//! # /* //! # /*
//! Logs::by_id(&conn, id) //! Logs::by_id(&*conn, id)
//! # */ //! # */
//! # Ok(()) //! # Ok(())
//! } //! }
@ -113,15 +113,15 @@
//! follows: //! follows:
//! //!
//! ```toml //! ```toml
//! // Option 1: //! # Option 1:
//! [global.databases] //! [global.databases]
//! sqlite_db = { url = "db.sqlite" } //! sqlite_db = { url = "db.sqlite" }
//! //!
//! // Option 2: //! # Option 2:
//! [global.databases.pg_db] //! [global.databases.pg_db]
//! url = "mysql://root:root@localhost/pg_db" //! url = "mysql://root:root@localhost/pg_db"
//! //!
//! // With a `pool_size` key: //! # With a `pool_size` key:
//! [global.databases] //! [global.databases]
//! sqlite_db = { url = "db.sqlite", pool_size = 20 } //! sqlite_db = { url = "db.sqlite", pool_size = 20 }
//! ``` //! ```
@ -308,7 +308,7 @@
//! //!
//! #[get("/")] //! #[get("/")]
//! fn my_handler(conn: MyDatabase) -> Data { //! fn my_handler(conn: MyDatabase) -> Data {
//! load_from_db(&conn) //! load_from_db(&*conn)
//! } //! }
//! # } //! # }
//! ``` //! ```

View File

@ -257,15 +257,9 @@ That's it! Whenever a connection to the database is needed, use your type as a
request guard: request guard:
```rust ```rust
impl Logs {
fn by_id(conn: &diesel::SqliteConnection, log_id: usize) -> Result<Logs> {
logs.filter(id.eq(log_id)).load(conn)
}
}
#[get("/logs/<id>")] #[get("/logs/<id>")]
fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> { fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> {
Logs::by_id(&conn, id) logs::filter(id.eq(log_id)).load(&*conn)
} }
``` ```