Skip to content

Commit b1b39cd

Browse files
authored
refactor: update to rust 2024 (#736)
* refactor: update to rust 2024 * chore: format code with rust 2024
1 parent 91d585f commit b1b39cd

33 files changed

+490
-351
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://github.com/sunng87/handlebars-rust"
1010
repository = "https://github.com/sunng87/handlebars-rust"
1111
documentation = "https://docs.rs/crate/handlebars/"
1212
readme = "README.md"
13-
edition = "2021"
13+
edition = "2024"
1414
rust-version = "1.85"
1515

1616
[lib]

benches/bench.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ extern crate criterion;
44
extern crate serde_derive;
55

66
use criterion::Criterion;
7-
use handlebars::{to_json, Context, Handlebars, Template};
7+
use handlebars::{Context, Handlebars, Template, to_json};
88
use serde_json::json;
99
use serde_json::value::Value as Json;
1010
use std::collections::BTreeMap;
1111

1212
#[cfg(unix)]
1313
use criterion::profiler::Profiler;
1414
#[cfg(unix)]
15-
use pprof::protos::Message;
16-
#[cfg(unix)]
1715
use pprof::ProfilerGuard;
16+
#[cfg(unix)]
17+
use pprof::protos::Message;
1818

1919
#[cfg(unix)]
20-
use std::fs::{create_dir_all, File};
20+
use std::fs::{File, create_dir_all};
2121
#[cfg(unix)]
2222
use std::io::Write;
2323
#[cfg(unix)]

examples/block_helper_macro_let.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use handlebars::{
22
BlockParamHolder, Context, Handlebars, Helper, Output, RenderContext, RenderError,
33
RenderErrorReason,
44
};
5-
use serde_json::{json, Value};
5+
use serde_json::{Value, json};
66

77
// a custom block helper to bind a variable name to a value
88
pub fn helper_let<'reg, 'rc>(

examples/decorator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::error::Error;
88
use serde_json::value::{Map, Value as Json};
99

1010
use handlebars::{
11-
to_json, Context, Decorator, Handlebars, Helper, JsonRender, Output, RenderContext,
12-
RenderError, RenderErrorReason,
11+
Context, Decorator, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError,
12+
RenderErrorReason, to_json,
1313
};
1414

1515
// default format helper

examples/dev_mode.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ fn main() {
2020
let hbs = Arc::new(handlebars());
2121

2222
let server = Server::http("127.0.0.1:3030").expect("Failed to start demo server.");
23-
println!("Edit ./examples/dev_mode/template.hbs and request http://localhost:3030 to see the change on the fly.");
23+
println!(
24+
"Edit ./examples/dev_mode/template.hbs and request http://localhost:3030 to see the change on the fly."
25+
);
2426

2527
for req in server.incoming_requests() {
2628
let result = hbs

examples/helper_macro.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::error::Error;
22

3-
use handlebars::{handlebars_helper, Handlebars, JsonRender};
4-
use serde_json::{json, Value};
5-
use time::format_description::parse;
3+
use handlebars::{Handlebars, JsonRender, handlebars_helper};
4+
use serde_json::{Value, json};
65
use time::OffsetDateTime;
6+
use time::format_description::parse;
77

88
// define a helper using helper
99
// a date format helper accept an `OffsetDateTime` as parameter

examples/render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use serde_json::value::{Map, Value as Json};
99
use std::error::Error;
1010

1111
use handlebars::{
12-
to_json, Context, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError,
13-
RenderErrorReason,
12+
Context, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError, RenderErrorReason,
13+
to_json,
1414
};
1515

1616
// define a custom helper

examples/render_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use std::fs::File;
1313
use std::io::{Read, Write};
1414

1515
use handlebars::{
16-
to_json, Context, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError,
17-
RenderErrorReason,
16+
Context, Handlebars, Helper, JsonRender, Output, RenderContext, RenderError, RenderErrorReason,
17+
to_json,
1818
};
1919

2020
// define a custom helper

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
format_strings = false
1+

src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::collections::BTreeMap;
22

33
use serde_json::value::Value as Json;
44

5+
use crate::Template;
56
use crate::error::RenderError;
67
use crate::local_vars::LocalVars;
7-
use crate::Template;
88

99
#[derive(Clone, Debug)]
1010
pub enum BlockParamHolder {

0 commit comments

Comments
 (0)