You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: resource.rs
    path of file: ./repos/actix-web/actix-web/src
    
    the code of the file until where you have to start completion: use std::{cell::RefCell, fmt, future::Future, rc::Rc};

use actix_http::Extensions;
use actix_router::{IntoPatterns, Patterns};
use actix_service::{
    apply, apply_fn_factory, boxed, fn_service, IntoServiceFactory, Service, ServiceFactory,
    ServiceFactoryExt, Transform,
};
use futures_core::future::LocalBoxFuture;
use futures_util::future::join_all;

use crate::{
    body::MessageBody,
    data::Data,
    dev::{ensure_leading_slash,
    
    pub fn new<T: IntoPatterns>(path: T) -> Resource {
        let fref = Rc::new(RefCell::new(None));

        Resource {
            routes: Vec::new(),
            rdef: path.patterns(),
            name: None,
            endpoint: ResourceEndpoint::new(fref.clone()),
            factory_ref: fref,
            guards: Vec::new(),
            app_data: None,
            default: boxed::factory(fn_service(|req: ServiceRequest| async {
                use crate::HttpMessage as _;

                let allowed = req.extensions().get::<guard::RegisteredMethods>().cloned();

                if let Some(methods) = allowed {
                    Ok(req.into_response(
                        HttpResponse::MethodNotAllowed()
                            .insert_header(header::Allow(methods.0))
                            .finish(),
                    ))
                } else {
                    Ok(req.into_response(HttpResponse::MethodNotAllowed()))
                }
            })),
        }
    }