diff --git a/src/app.rs b/src/app.rs index fdedb0a7..6a4b97b6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -459,8 +459,8 @@ where { fn into_factory(self) -> AppInit { AppInit { - data: Rc::new(self.data), - data_factories: Rc::new(self.data_factories), + data: self.data.into_boxed_slice().into(), + data_factories: self.data_factories.into_boxed_slice().into(), endpoint: self.endpoint, services: Rc::new(RefCell::new(self.services)), external: RefCell::new(self.external), diff --git a/src/app_service.rs b/src/app_service.rs index 98d8c8a8..e5f8dd9c 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -39,8 +39,8 @@ where { pub(crate) endpoint: T, pub(crate) extensions: RefCell>, - pub(crate) data: Rc>>, - pub(crate) data_factories: Rc>, + pub(crate) data: Rc<[Box]>, + pub(crate) data_factories: Rc<[FnDataFactory]>, pub(crate) services: Rc>>>, pub(crate) default: Option>, pub(crate) factory_ref: Rc>>, @@ -88,15 +88,15 @@ where // complete pipeline creation *self.factory_ref.borrow_mut() = Some(AppRoutingFactory { default, - services: Rc::new( - services - .into_iter() - .map(|(mut rdef, srv, guards, nested)| { - rmap.add(&mut rdef, nested); - (rdef, srv, RefCell::new(guards)) - }) - .collect(), - ), + services: services + .into_iter() + .map(|(mut rdef, srv, guards, nested)| { + rmap.add(&mut rdef, nested); + (rdef, srv, RefCell::new(guards)) + }) + .collect::>() + .into_boxed_slice() + .into(), }); // external resources @@ -147,7 +147,7 @@ where rmap: Rc, config: AppConfig, - data: Rc>>, + data: Rc<[Box]>, extensions: Option, _t: PhantomData, @@ -273,7 +273,7 @@ where } pub struct AppRoutingFactory { - services: Rc>)>>, + services: Rc<[(ResourceDef, HttpNewService, RefCell>)]>, default: Rc, } diff --git a/src/config.rs b/src/config.rs index 0f49288e..f7bebb4c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -31,7 +31,7 @@ pub struct AppService { Option, Option>, )>, - service_data: Rc>>, + service_data: Rc<[Box]>, } impl AppService { @@ -39,7 +39,7 @@ impl AppService { pub(crate) fn new( config: AppConfig, default: Rc, - service_data: Rc>>, + service_data: Rc<[Box]>, ) -> Self { AppService { config, diff --git a/src/lib.rs b/src/lib.rs index edc8456b..327cba95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,6 @@ #![deny(rust_2018_idioms)] #![allow(clippy::needless_doctest_main, clippy::type_complexity)] -#![allow(clippy::rc_buffer)] // FXIME: We should take a closer look for the warnings at some point. #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] diff --git a/src/route.rs b/src/route.rs index 129a6733..e9e9d1f5 100644 --- a/src/route.rs +++ b/src/route.rs @@ -1,3 +1,5 @@ +#![allow(clippy::rc_buffer)] // inner value is mutated before being shared (`Rc::get_mut`) + use std::future::Future; use std::pin::Pin; use std::rc::Rc; diff --git a/src/scope.rs b/src/scope.rs index 2520fd7a..1c5d8700 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -442,16 +442,17 @@ where *self.factory_ref.borrow_mut() = Some(ScopeFactory { data: self.data.take().map(Rc::new), default: self.default.clone(), - services: Rc::new( - cfg.into_services() - .1 - .into_iter() - .map(|(mut rdef, srv, guards, nested)| { - rmap.add(&mut rdef, nested); - (rdef, srv, RefCell::new(guards)) - }) - .collect(), - ), + services: cfg + .into_services() + .1 + .into_iter() + .map(|(mut rdef, srv, guards, nested)| { + rmap.add(&mut rdef, nested); + (rdef, srv, RefCell::new(guards)) + }) + .collect::>() + .into_boxed_slice() + .into(), }); // get guards @@ -473,7 +474,7 @@ where pub struct ScopeFactory { data: Option>, - services: Rc>)>>, + services: Rc<[(ResourceDef, HttpNewService, RefCell>)]>, default: Rc>>>, }