mirror of https://github.com/fafhrd91/actix-web
Replace most Rc<Vec<_>> with Rc<[_]>
This commit is contained in:
parent
34b23f31c9
commit
ec3c2975a6
|
@ -459,8 +459,8 @@ where
|
|||
{
|
||||
fn into_factory(self) -> AppInit<T, B> {
|
||||
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),
|
||||
|
|
|
@ -39,8 +39,8 @@ where
|
|||
{
|
||||
pub(crate) endpoint: T,
|
||||
pub(crate) extensions: RefCell<Option<Extensions>>,
|
||||
pub(crate) data: Rc<Vec<Box<dyn DataFactory>>>,
|
||||
pub(crate) data_factories: Rc<Vec<FnDataFactory>>,
|
||||
pub(crate) data: Rc<[Box<dyn DataFactory>]>,
|
||||
pub(crate) data_factories: Rc<[FnDataFactory]>,
|
||||
pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>,
|
||||
pub(crate) default: Option<Rc<HttpNewService>>,
|
||||
pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
|
||||
|
@ -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::<Vec<_>>()
|
||||
.into_boxed_slice()
|
||||
.into(),
|
||||
});
|
||||
|
||||
// external resources
|
||||
|
@ -147,7 +147,7 @@ where
|
|||
|
||||
rmap: Rc<ResourceMap>,
|
||||
config: AppConfig,
|
||||
data: Rc<Vec<Box<dyn DataFactory>>>,
|
||||
data: Rc<[Box<dyn DataFactory>]>,
|
||||
extensions: Option<Extensions>,
|
||||
|
||||
_t: PhantomData<B>,
|
||||
|
@ -273,7 +273,7 @@ where
|
|||
}
|
||||
|
||||
pub struct AppRoutingFactory {
|
||||
services: Rc<Vec<(ResourceDef, HttpNewService, RefCell<Option<Guards>>)>>,
|
||||
services: Rc<[(ResourceDef, HttpNewService, RefCell<Option<Guards>>)]>,
|
||||
default: Rc<HttpNewService>,
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ pub struct AppService {
|
|||
Option<Guards>,
|
||||
Option<Rc<ResourceMap>>,
|
||||
)>,
|
||||
service_data: Rc<Vec<Box<dyn DataFactory>>>,
|
||||
service_data: Rc<[Box<dyn DataFactory>]>,
|
||||
}
|
||||
|
||||
impl AppService {
|
||||
|
@ -39,7 +39,7 @@ impl AppService {
|
|||
pub(crate) fn new(
|
||||
config: AppConfig,
|
||||
default: Rc<HttpNewService>,
|
||||
service_data: Rc<Vec<Box<dyn DataFactory>>>,
|
||||
service_data: Rc<[Box<dyn DataFactory>]>,
|
||||
) -> Self {
|
||||
AppService {
|
||||
config,
|
||||
|
|
23
src/scope.rs
23
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::<Vec<_>>()
|
||||
.into_boxed_slice()
|
||||
.into(),
|
||||
});
|
||||
|
||||
// get guards
|
||||
|
@ -473,7 +474,7 @@ where
|
|||
|
||||
pub struct ScopeFactory {
|
||||
data: Option<Rc<Extensions>>,
|
||||
services: Rc<Vec<(ResourceDef, HttpNewService, RefCell<Option<Guards>>)>>,
|
||||
services: Rc<[(ResourceDef, HttpNewService, RefCell<Option<Guards>>)]>,
|
||||
default: Rc<RefCell<Option<Rc<HttpNewService>>>>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue