Skip to content

Commit d652c9e

Browse files
authored
Merge pull request #129 from mkantor/bump-rust-edition
Switch to Rust 2024 edition.
2 parents 9444ed4 + e5ac196 commit d652c9e

File tree

13 files changed

+69
-102
lines changed

13 files changed

+69
-102
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ categories = ["web-programming::http-server", "command-line-utilities"]
99
keywords = ["web", "server", "http", "templating", "handlebars"]
1010
readme = "README.md"
1111
license = "GPL-3.0"
12-
edition = "2021"
12+
edition = "2024"
1313
include = [
1414
"src/**/*",
1515
"Cargo.toml",

benches/load_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use actix_web::error::PayloadError;
44
use actix_web::http::StatusCode;
55
use actix_web::test::unused_addr;
66
use bytes::{Bytes, BytesMut};
7-
use criterion::{criterion_main, BenchmarkId, Criterion};
7+
use criterion::{BenchmarkId, Criterion, criterion_main};
88
use futures::FutureExt;
9-
use futures::{future, Stream, TryStreamExt};
9+
use futures::{Stream, TryStreamExt, future};
1010
use lazy_static::lazy_static;
1111
use mime_guess::MimeGuess;
1212
use operator::content::ContentDirectory;

src/cli.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,9 @@ mod tests {
257257
);
258258
let output_as_str = str::from_utf8(output.as_slice()).expect("Output was not UTF-8");
259259
assert_eq!(
260-
output_as_str,
261-
expected_output,
260+
output_as_str, expected_output,
262261
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
263-
template,
264-
expected_output,
265-
output_as_str
262+
template, expected_output, output_as_str
266263
);
267264
}
268265
}
@@ -303,13 +300,10 @@ mod tests {
303300
);
304301
let output_as_str = str::from_utf8(output.as_slice()).expect("Output was not UTF-8");
305302
assert_eq!(
306-
output_as_str,
307-
expected_output,
308-
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
309-
template,
310-
expected_output,
311-
output_as_str
312-
);
303+
output_as_str, expected_output,
304+
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
305+
template, expected_output, output_as_str
306+
);
313307
}
314308

315309
#[test]
@@ -329,12 +323,9 @@ mod tests {
329323
);
330324
let output_as_str = str::from_utf8(output.as_slice()).expect("Output was not UTF-8");
331325
assert_eq!(
332-
output_as_str,
333-
expected_output,
326+
output_as_str, expected_output,
334327
"Template rendering for content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
335-
route,
336-
expected_output,
337-
output_as_str
328+
route, expected_output, output_as_str
338329
);
339330
}
340331

@@ -355,12 +346,9 @@ mod tests {
355346
);
356347
let output_as_str = str::from_utf8(output.as_slice()).expect("Output was not UTF-8");
357348
assert_eq!(
358-
output_as_str,
359-
expected_output,
349+
output_as_str, expected_output,
360350
"Template rendering for content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
361-
route,
362-
expected_output,
363-
output_as_str
351+
route, expected_output, output_as_str
364352
);
365353
}
366354

src/content/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use super::StreamError;
66
use crate::bug_message;
77
use bytes::Bytes;
8-
use futures::future::{Future, FutureExt, LocalBoxFuture};
98
use futures::Stream;
9+
use futures::future::{Future, FutureExt, LocalBoxFuture};
1010
use std::cmp;
1111
use std::fs::File;
1212
use std::io::ErrorKind::Interrupted;

src/content/content_directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl ContentFile {
122122
return Err(ContentFileError(format!(
123123
"Non-unicode directory root (path is similar to '{}')",
124124
content_directory_root.display(),
125-
)))
125+
)));
126126
}
127127
};
128128

src/content/content_engine.rs

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use super::*;
77
use crate::bug_message;
88
use handlebars::{self, Handlebars};
99
use mime_guess::MimeGuess;
10-
use std::collections::hash_map::Entry;
1110
use std::collections::HashMap;
11+
use std::collections::hash_map::Entry;
1212
use std::path::Path;
1313
use std::sync::{Arc, RwLock};
1414
use thiserror::Error;
@@ -149,13 +149,13 @@ where
149149
return Err(ContentLoadingError::ContentFileNameError(format!(
150150
"Content file name '{}' has too many extensions.",
151151
entry.relative_path
152-
)))
152+
)));
153153
}
154154
[] => {
155155
return Err(ContentLoadingError::ContentFileNameError(format!(
156156
"Content file names must have extensions, but '{}' does not.",
157157
entry.relative_path
158-
)))
158+
)));
159159
}
160160
}
161161
}
@@ -222,14 +222,12 @@ where
222222
// have the executable bit set. They are evaluated when rendered.
223223
[first_extension, Self::HANDLEBARS_FILE_EXTENSION] => {
224224
if content.is_executable {
225-
return Err(ContentLoadingError::ContentFileNameError(
226-
format!(
227-
"The content file '{}' appears to be a handlebars file (because it ends in '.{}'), \
225+
return Err(ContentLoadingError::ContentFileNameError(format!(
226+
"The content file '{}' appears to be a handlebars file (because it ends in '.{}'), \
228227
but it is also executable. It must be one or the other.",
229-
content.relative_path,
230-
Self::HANDLEBARS_FILE_EXTENSION,
231-
),
232-
));
228+
content.relative_path,
229+
Self::HANDLEBARS_FILE_EXTENSION,
230+
)));
233231
}
234232

235233
let mime = MimeGuess::from_ext(first_extension)
@@ -480,12 +478,9 @@ mod tests {
480478
let actual_output = media_to_string(rendered);
481479

482480
assert_eq!(
483-
actual_output,
484-
expected_output,
481+
actual_output, expected_output,
485482
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
486-
template,
487-
expected_output,
488-
actual_output,
483+
template, expected_output, actual_output,
489484
);
490485
}
491486
}
@@ -539,12 +534,9 @@ mod tests {
539534
let actual_output = media_to_string(rendered);
540535

541536
assert_eq!(
542-
actual_output,
543-
expected_output,
537+
actual_output, expected_output,
544538
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
545-
template,
546-
expected_output,
547-
actual_output,
539+
template, expected_output, actual_output,
548540
);
549541
}
550542

@@ -573,12 +565,9 @@ mod tests {
573565
let actual_output = media_to_string(rendered);
574566

575567
assert_eq!(
576-
actual_output,
577-
expected_output,
568+
actual_output, expected_output,
578569
"Rendering content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
579-
route,
580-
expected_output,
581-
actual_output,
570+
route, expected_output, actual_output,
582571
);
583572
}
584573

@@ -639,12 +628,9 @@ mod tests {
639628
let actual_output = media_to_string(rendered);
640629

641630
assert_eq!(
642-
actual_output,
643-
expected_output,
631+
actual_output, expected_output,
644632
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
645-
template,
646-
expected_output,
647-
actual_output,
633+
template, expected_output, actual_output,
648634
);
649635
}
650636

@@ -709,12 +695,9 @@ mod tests {
709695
let actual_output = media_to_string(rendered);
710696

711697
assert_eq!(
712-
actual_output,
713-
expected_output,
698+
actual_output, expected_output,
714699
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
715-
template,
716-
expected_output,
717-
actual_output,
700+
template, expected_output, actual_output,
718701
);
719702
}
720703

@@ -750,12 +733,9 @@ mod tests {
750733
let actual_output = media_to_string(rendered);
751734

752735
assert_eq!(
753-
actual_output,
754-
expected_output,
736+
actual_output, expected_output,
755737
"Template rendering for `{}` did not produce the expected output (\"{}\"), instead got \"{}\"",
756-
template,
757-
expected_output,
758-
actual_output,
738+
template, expected_output, actual_output,
759739
);
760740
}
761741

@@ -949,12 +929,9 @@ mod tests {
949929
let actual_output = media_to_string(rendered);
950930

951931
assert_eq!(
952-
actual_output,
953-
expected_output,
932+
actual_output, expected_output,
954933
"Rendering content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
955-
route,
956-
expected_output,
957-
actual_output,
934+
route, expected_output, actual_output,
958935
);
959936
}
960937

@@ -980,12 +957,9 @@ mod tests {
980957
let actual_output = media_to_string(rendered);
981958

982959
assert_eq!(
983-
actual_output,
984-
expected_output1,
960+
actual_output, expected_output1,
985961
"Rendering content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
986-
route1,
987-
expected_output1,
988-
actual_output,
962+
route1, expected_output1, actual_output,
989963
);
990964

991965
let route2 = route("/subdirectory/pwd");
@@ -1003,12 +977,9 @@ mod tests {
1003977
let actual_output = media_to_string(rendered);
1004978

1005979
assert_eq!(
1006-
actual_output,
1007-
expected_output2,
980+
actual_output, expected_output2,
1008981
"Rendering content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
1009-
route2,
1010-
expected_output2,
1011-
actual_output,
982+
route2, expected_output2, actual_output,
1012983
);
1013984
}
1014985

@@ -1099,12 +1070,9 @@ mod tests {
10991070
let actual_output = media_to_string(rendered);
11001071

11011072
assert_eq!(
1102-
actual_output,
1103-
expected_output,
1073+
actual_output, expected_output,
11041074
"Rendering content at '{}' did not produce the expected output (\"{}\"), instead got \"{}\"",
1105-
route,
1106-
expected_output,
1107-
actual_output,
1075+
route, expected_output, actual_output,
11081076
);
11091077
}
11101078

src/content/content_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl ContentIndexEntries {
8282
failed_route: route.clone(),
8383
message: format!(
8484
"There is already a resource at '{conficting_route}', but that needs to be a directory to accommodate the new route.",
85-
)
85+
),
8686
});
8787
}
8888
};

src/content/content_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ impl Executable {
284284
mod tests {
285285
use super::super::test_lib::*;
286286
use super::*;
287+
use crate::ServerInfo;
287288
use crate::content::content_index::ContentIndexEntries;
288289
use crate::test_lib::*;
289-
use crate::ServerInfo;
290290
use ::mime;
291291
use maplit::hashmap;
292292
use std::fs;

src/content/content_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl Render for ContentRepresentations {
9191
)))
9292
} else {
9393
Ok(rendered)
94-
}
94+
};
9595
}
9696
Err(error) => {
9797
log::warn!("Rendering failure: {error}");

src/content/handlebars_helpers/get.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,16 @@ where
122122
let modified_context_data_as_json =
123123
mem::take(Rc::make_mut(modified_context).data_mut());
124124
match modified_context_data_as_json {
125-
serde_json::Value::Object(modified_context_data_as_json_map) => modified_context_data_as_json_map,
125+
serde_json::Value::Object(modified_context_data_as_json_map) => {
126+
modified_context_data_as_json_map
127+
}
126128
_ => {
127-
return Err(handlebars::RenderError::from(handlebars::RenderErrorReason::Other(format!(
128-
"The `get \"{route}\"` helper call failed because the pre-existing handlebars render context \
129+
return Err(handlebars::RenderError::from(
130+
handlebars::RenderErrorReason::Other(format!(
131+
"The `get \"{route}\"` helper call failed because the pre-existing handlebars render context \
129132
was not an object (it was `{modified_context_data_as_json}`)."
130-
))))
133+
)),
134+
));
131135
}
132136
}
133137
}

0 commit comments

Comments
 (0)