From 746023fe1ff2f883e6a49d69466842f3981bcf5c Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 10 Dec 2018 22:20:28 -0800 Subject: [PATCH] Use '&*' in database docs for reliable deref coercions. Resolves #855. --- contrib/lib/src/databases.rs | 10 +++++----- site/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 index 49798b98..07d28ed6 100644 --- a/contrib/lib/src/databases.rs +++ b/contrib/lib/src/databases.rs @@ -91,7 +91,7 @@ //! #[get("/logs/")] //! fn get_logs(conn: LogsDbConn, id: usize) -> Result { //! # /* -//! 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 index 3e5110e1..00a75120 100644 --- 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.filter(id.eq(log_id)).load(conn) - } -} - #[get("/logs/")] fn get_logs(conn: LogsDbConn, id: usize) -> Result { - Logs::by_id(&conn, id) + logs::filter(id.eq(log_id)).load(&*conn) } ```