@@ -26,12 +26,12 @@ use std::{collections::HashMap, ops::Deref, rc::Rc};
2626/// use actix_web::App;
2727///
2828/// fn main() {
29- /// // serve root directory with default options:
30- /// // - resolve index.html
29+ /// // serve root directory with default options:
30+ /// // - resolve index.html
3131/// let files: HashMap<&'static str, static_files::Resource> = HashMap::new();
3232/// let app = App::new()
3333/// .service(actix_web_static_files::ResourceFiles::new("/", files));
34- /// // or subpath with additional option to not resolve index.html
34+ /// // or subpath with additional option to not resolve index.html
3535/// let files: HashMap<&'static str, static_files::Resource> = HashMap::new();
3636/// let app = App::new()
3737/// .service(actix_web_static_files::ResourceFiles::new("/imgs", files)
@@ -54,6 +54,7 @@ pub struct ResourceFilesInner {
5454const INDEX_HTML : & str = "index.html" ;
5555
5656impl ResourceFiles {
57+ #[ must_use]
5758 pub fn new ( path : & str , files : HashMap < & ' static str , Resource > ) -> Self {
5859 let inner = ResourceFilesInner {
5960 path : path. into ( ) ,
@@ -69,6 +70,7 @@ impl ResourceFiles {
6970
7071 /// By default trying to resolve '.../' to '.../index.html' if it exists.
7172 /// Turn off this resolution by calling this function.
73+ #[ must_use]
7274 pub fn do_not_resolve_defaults ( mut self ) -> Self {
7375 self . not_resolve_defaults = true ;
7476 self
@@ -77,6 +79,7 @@ impl ResourceFiles {
7779 /// Resolves not found references to this path.
7880 ///
7981 /// This can be useful for angular-like applications.
82+ #[ must_use]
8083 pub fn resolve_not_found_to < S : ToString > ( mut self , path : S ) -> Self {
8184 self . not_found_resolves_to = Some ( path. to_string ( ) ) ;
8285 self
@@ -85,15 +88,17 @@ impl ResourceFiles {
8588 /// Resolves not found references to root path.
8689 ///
8790 /// This can be useful for angular-like applications.
91+ #[ must_use]
8892 pub fn resolve_not_found_to_root ( self ) -> Self {
8993 self . resolve_not_found_to ( INDEX_HTML )
9094 }
9195
92- /// If this is called, we will use an [actix_web::guard:: Guard] to check if this request should be handled.
96+ /// If this is called, we will use a [` Guard` ] to check if this request should be handled.
9397 /// If set to true, we skip using the handler for files that haven't been found, instead of sending 404s.
9498 /// Would be ignored, if `resolve_not_found_to` or `resolve_not_found_to_root` is used.
9599 ///
96100 /// Can be useful if you want to share files on a (sub)path that's also used by a different route handler.
101+ #[ must_use]
97102 pub fn skip_handler_when_not_found ( mut self ) -> Self {
98103 self . use_guard = true ;
99104 self
@@ -178,9 +183,9 @@ impl HttpServiceFactory for ResourceFiles {
178183}
179184
180185impl ServiceFactory < ServiceRequest > for ResourceFiles {
181- type Config = ( ) ;
182186 type Response = ServiceResponse ;
183187 type Error = Error ;
188+ type Config = ( ) ;
184189 type Service = ResourceFilesService ;
185190 type InitError = ( ) ;
186191 type Future = LocalBoxFuture < ' static , Result < Self :: Service , Self :: InitError > > ;
@@ -383,7 +388,7 @@ fn get_pathbuf(path: &str) -> Result<String, UriSegmentError> {
383388 } else if cfg ! ( windows) && segment. contains ( '\\' ) {
384389 return Err ( UriSegmentError :: BadChar ( '\\' ) ) ;
385390 } else {
386- buf. push ( segment)
391+ buf. push ( segment) ;
387392 }
388393 }
389394
0 commit comments