diff --git a/src/data.rs b/src/data.rs index 01d36569b..dad97ba87 100644 --- a/src/data.rs +++ b/src/data.rs @@ -20,12 +20,11 @@ pub(crate) type FnDataFactory = /// Application data. /// -/// Application data is an arbitrary data attached to the app. -/// Application data is available to all routes and could be added -/// during application configuration process -/// with `App::data()` method. +/// Application data is a piece of arbitrary data attached to the app. +/// Application data is available to all routes and can be added +/// during the application configuration process via `App::data()`. /// -/// Application data could be accessed by using `Data` +/// Application data can be accessed by using `Data` /// extractor where `T` is data type. /// /// **Note**: http server accepts an application factory rather than @@ -33,9 +32,7 @@ pub(crate) type FnDataFactory = /// instance for each thread, thus application data must be constructed /// multiple times. If you want to share data between different /// threads, a shareable object should be used, e.g. `Send + Sync`. Application -/// data does not need to be `Send` or `Sync`. Internally `Data` type -/// uses `Arc`. if your data implements `Send` + `Sync` traits you can -/// use `web::Data::new()` and avoid double `Arc`. +/// data does not need to be `Send` or `Sync`. Internally `Data` uses `Arc`. /// /// If route data is not set for a handler, using `Data` extractor would /// cause *Internal Server Error* response. @@ -48,7 +45,7 @@ pub(crate) type FnDataFactory = /// counter: usize, /// } /// -/// /// Use `Data` extractor to access data in handler. +/// /// Use the `Data` extractor to access data in a handler. /// async fn index(data: web::Data>) -> impl Responder { /// let mut data = data.lock().unwrap(); /// data.counter += 1; @@ -71,10 +68,6 @@ pub struct Data(Arc); impl Data { /// Create new `Data` instance. - /// - /// Internally `Data` type uses `Arc`. if your data implements - /// `Send` + `Sync` traits you can use `web::Data::new()` and - /// avoid double `Arc`. pub fn new(state: T) -> Data { Data(Arc::new(state)) }