Skip to content

Commit fef6562

Browse files
committed
Minor lints and cleanups
1 parent 683116e commit fef6562

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
## <a name='Legal'></a>Legal
2121

22-
Dual-licensed under `MIT` or the [UNLICENSE](http://unlicense.org/).
22+
Dual-licensed under `MIT` or the [Unlicense](http://unlicense.org/).
2323

2424
## <a name='Features'></a>Features
2525

@@ -159,7 +159,7 @@ Reference resources in your `HTML` (`static/index.html`):
159159
160160
```html
161161
<!DOCTYPE html>
162-
<html>
162+
<html lang="en">
163163
<head>
164164
<meta charset="utf-8">
165165
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
2222
## <a name='Legal'></a>Legal
2323
24-
Dual-licensed under `MIT` or the [UNLICENSE](http://unlicense.org/).
24+
Dual-licensed under `MIT` or the [Unlicense](http://unlicense.org/).
2525
2626
## <a name='Features'></a>Features
2727
28-
- Embed static resources in single self-contained executuble
28+
- Embed static resources in single self-contained executable
2929
- Serve static resources in `actix-web`
3030
- Install dependencies with [npm](https://npmjs.org) package manager
3131
- Run custom `npm` run commands (such as [webpack](https://webpack.js.org/))

src/resource_files.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
5454
const INDEX_HTML: &str = "index.html";
5555

5656
impl 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

180185
impl 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

templates/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
## <a name='Legal'></a>Legal
2121

22-
Dual-licensed under `MIT` or the [UNLICENSE](http://unlicense.org/).
22+
Dual-licensed under `MIT` or the [Unlicense](http://unlicense.org/).
2323

2424
## <a name='Features'></a>Features
2525

26-
- Embed static resources in single self-contained executuble
26+
- Embed static resources in single self-contained executable
2727
- Serve static resources in `actix-web`
2828
- Install dependencies with [npm](https://npmjs.org) package manager
2929
- Run custom `npm` run commands (such as [webpack](https://webpack.js.org/))

0 commit comments

Comments
 (0)