Add missing documentation for the `run()` method generated by `#[database]`.

Resolves #1704.
This commit is contained in:
Petr Portnov 2021-06-16 18:23:08 +03:00 committed by Jeb Rosen
parent c1b14084f9
commit d9858cf3c7
2 changed files with 14 additions and 2 deletions

View File

@ -30,7 +30,7 @@ use proc_macro::TokenStream;
/// retrieves a connection from the database pool or fails with a
/// `Status::ServiceUnavailable` if connecting to the database times out.
///
/// The macro also generates two inherent methods on the decorated type:
/// The macro also generates three inherent methods on the decorated type:
///
/// * `fn fairing() -> impl Fairing`
///
@ -42,6 +42,12 @@ use proc_macro::TokenStream;
/// Retrieves a connection wrapper from the configured pool. Returns `Some`
/// as long as `Self::fairing()` has been attached.
///
/// * `async fn run<R: Send + 'static>(&self, impl FnOnce(&mut Db) -> R + Send + 'static) -> R`
///
/// Runs the specified function or closure, providing it access to the
/// underlying database connection (`&mut Db`). Returns the value returned
/// by the function or closure.
///
/// [`FromRequest`]: rocket::request::FromRequest
#[proc_macro_attribute]
pub fn database(attr: TokenStream, input: TokenStream) -> TokenStream {

View File

@ -187,7 +187,7 @@
//! retrieves a connection from the database pool or fails with a
//! `Status::ServiceUnavailable` if connecting to the database times out.
//!
//! The macro also generates two inherent methods on the decorated type:
//! The macro also generates three inherent methods on the decorated type:
//!
//! * `fn fairing() -> impl Fairing`
//!
@ -199,6 +199,12 @@
//! Retrieves a connection wrapper from the configured pool. Returns `Some`
//! as long as `Self::fairing()` has been attached.
//!
//! * `async fn run<R: Send + 'static>(&self, impl FnOnce(&mut Db) -> R + Send + 'static) -> R`
//!
//! Runs the specified function or closure, providing it access to the
//! underlying database connection (`&mut Db`). Returns the value returned
//! by the function or closure.
//!
//! The attribute can only be applied to unit-like structs with one type. The
//! internal type of the structure must implement [`Poolable`].
//!