Rocket

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 746023fe1ff2f883e6a49d69466842f3981bcf5c
parent ba96de314cec8bd231742b2b6654c00ad848d490
Author: Sergio Benitez <sb@sergio.bz>
Date:   Mon, 10 Dec 2018 22:20:28 -0800

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

Resolves #855.

Diffstat:
Mcontrib/lib/src/databases.rs | 10+++++-----
Msite/guide/6-state.md | 8+-------
2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/contrib/lib/src/databases.rs b/contrib/lib/src/databases.rs @@ -91,7 +91,7 @@ //! #[get("/logs/<id>")] //! fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> { //! # /* -//! Logs::by_id(&conn, id) +//! Logs::by_id(&*conn, id) //! # */ //! # Ok(()) //! } @@ -113,15 +113,15 @@ //! follows: //! //! ```toml -//! // Option 1: +//! # Option 1: //! [global.databases] //! sqlite_db = { url = "db.sqlite" } //! -//! // Option 2: +//! # Option 2: //! [global.databases.pg_db] //! url = "mysql://root:root@localhost/pg_db" //! -//! // With a `pool_size` key: +//! # With a `pool_size` key: //! [global.databases] //! sqlite_db = { url = "db.sqlite", pool_size = 20 } //! ``` @@ -308,7 +308,7 @@ //! //! #[get("/")] //! fn my_handler(conn: MyDatabase) -> Data { -//! load_from_db(&conn) +//! load_from_db(&*conn) //! } //! # } //! ``` diff --git a/site/guide/6-state.md b/site/guide/6-state.md @@ -257,15 +257,9 @@ That's it! Whenever a connection to the database is needed, use your type as a request guard: ```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>")] fn get_logs(conn: LogsDbConn, id: usize) -> Result<Logs> { - Logs::by_id(&conn, id) + logs::filter(id.eq(log_id)).load(&*conn) } ```