1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

Fix clippy::rc_buffer (#1728)

This commit is contained in:
Jonas Platte 2020-10-10 02:26:05 +02:00 committed by GitHub
parent 34b23f31c9
commit d765e9099d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 29 deletions

View File

@ -459,8 +459,8 @@ where
{ {
fn into_factory(self) -> AppInit<T, B> { fn into_factory(self) -> AppInit<T, B> {
AppInit { AppInit {
data: Rc::new(self.data), data: self.data.into_boxed_slice().into(),
data_factories: Rc::new(self.data_factories), data_factories: self.data_factories.into_boxed_slice().into(),
endpoint: self.endpoint, endpoint: self.endpoint,
services: Rc::new(RefCell::new(self.services)), services: Rc::new(RefCell::new(self.services)),
external: RefCell::new(self.external), external: RefCell::new(self.external),

View File

@ -39,8 +39,8 @@ where
{ {
pub(crate) endpoint: T, pub(crate) endpoint: T,
pub(crate) extensions: RefCell<Option<Extensions>>, pub(crate) extensions: RefCell<Option<Extensions>>,
pub(crate) data: Rc<Vec<Box<dyn DataFactory>>>, pub(crate) data: Rc<[Box<dyn DataFactory>]>,
pub(crate) data_factories: Rc<Vec<FnDataFactory>>, pub(crate) data_factories: Rc<[FnDataFactory]>,
pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>, pub(crate) services: Rc<RefCell<Vec<Box<dyn AppServiceFactory>>>>,
pub(crate) default: Option<Rc<HttpNewService>>, pub(crate) default: Option<Rc<HttpNewService>>,
pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>, pub(crate) factory_ref: Rc<RefCell<Option<AppRoutingFactory>>>,
@ -88,15 +88,15 @@ where
// complete pipeline creation // complete pipeline creation
*self.factory_ref.borrow_mut() = Some(AppRoutingFactory { *self.factory_ref.borrow_mut() = Some(AppRoutingFactory {
default, default,
services: Rc::new( services: services
services .into_iter()
.into_iter() .map(|(mut rdef, srv, guards, nested)| {
.map(|(mut rdef, srv, guards, nested)| { rmap.add(&mut rdef, nested);
rmap.add(&mut rdef, nested); (rdef, srv, RefCell::new(guards))
(rdef, srv, RefCell::new(guards)) })
}) .collect::<Vec<_>>()
.collect(), .into_boxed_slice()
), .into(),
}); });
// external resources // external resources
@ -147,7 +147,7 @@ where
rmap: Rc<ResourceMap>, rmap: Rc<ResourceMap>,
config: AppConfig, config: AppConfig,
data: Rc<Vec<Box<dyn DataFactory>>>, data: Rc<[Box<dyn DataFactory>]>,
extensions: Option<Extensions>, extensions: Option<Extensions>,
_t: PhantomData<B>, _t: PhantomData<B>,
@ -273,7 +273,7 @@ where
} }
pub struct AppRoutingFactory { pub struct AppRoutingFactory {
services: Rc<Vec<(ResourceDef, HttpNewService, RefCell<Option<Guards>>)>>, services: Rc<[(ResourceDef, HttpNewService, RefCell<Option<Guards>>)]>,
default: Rc<HttpNewService>, default: Rc<HttpNewService>,
} }

View File

@ -31,7 +31,7 @@ pub struct AppService {
Option<Guards>, Option<Guards>,
Option<Rc<ResourceMap>>, Option<Rc<ResourceMap>>,
)>, )>,
service_data: Rc<Vec<Box<dyn DataFactory>>>, service_data: Rc<[Box<dyn DataFactory>]>,
} }
impl AppService { impl AppService {
@ -39,7 +39,7 @@ impl AppService {
pub(crate) fn new( pub(crate) fn new(
config: AppConfig, config: AppConfig,
default: Rc<HttpNewService>, default: Rc<HttpNewService>,
service_data: Rc<Vec<Box<dyn DataFactory>>>, service_data: Rc<[Box<dyn DataFactory>]>,
) -> Self { ) -> Self {
AppService { AppService {
config, config,

View File

@ -67,7 +67,6 @@
#![deny(rust_2018_idioms)] #![deny(rust_2018_idioms)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity)] #![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_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]

View File

@ -1,3 +1,5 @@
#![allow(clippy::rc_buffer)] // inner value is mutated before being shared (`Rc::get_mut`)
use std::future::Future; use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::rc::Rc; use std::rc::Rc;

View File

@ -442,16 +442,17 @@ where
*self.factory_ref.borrow_mut() = Some(ScopeFactory { *self.factory_ref.borrow_mut() = Some(ScopeFactory {
data: self.data.take().map(Rc::new), data: self.data.take().map(Rc::new),
default: self.default.clone(), default: self.default.clone(),
services: Rc::new( services: cfg
cfg.into_services() .into_services()
.1 .1
.into_iter() .into_iter()
.map(|(mut rdef, srv, guards, nested)| { .map(|(mut rdef, srv, guards, nested)| {
rmap.add(&mut rdef, nested); rmap.add(&mut rdef, nested);
(rdef, srv, RefCell::new(guards)) (rdef, srv, RefCell::new(guards))
}) })
.collect(), .collect::<Vec<_>>()
), .into_boxed_slice()
.into(),
}); });
// get guards // get guards
@ -473,7 +474,7 @@ where
pub struct ScopeFactory { pub struct ScopeFactory {
data: Option<Rc<Extensions>>, 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>>>>, default: Rc<RefCell<Option<Rc<HttpNewService>>>>,
} }