Skip to content

Commit c7fce66

Browse files
Remove humansize dependency
1 parent f1b8bd1 commit c7fce66

File tree

10 files changed

+6
-21
lines changed

10 files changed

+6
-21
lines changed

rinja/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ rustdoc-args = ["--generate-link-to-definition", "--cfg=docsrs"]
2121
maintenance = { status = "actively-developed" }
2222

2323
[features]
24-
default = ["config", "humansize", "urlencode"]
24+
default = ["config", "urlencode"]
2525
full = ["default", "code-in-doc", "serde_json"]
2626
code-in-doc = ["rinja_derive/code-in-doc"]
2727
config = ["rinja_derive/config"]
28-
humansize = ["rinja_derive/humansize", "dep:humansize"]
2928
serde_json = ["rinja_derive/serde_json", "dep:serde", "dep:serde_json"]
3029
urlencode = ["rinja_derive/urlencode", "dep:percent-encoding"]
3130

@@ -39,7 +38,6 @@ with-warp = ["rinja_derive/with-warp"]
3938
[dependencies]
4039
rinja_derive = { version = "=0.3.5", path = "../rinja_derive" }
4140

42-
humansize = { version = "2", optional = true }
4341
num-traits = { version = "0.2.6", optional = true }
4442
percent-encoding = { version = "2.1.0", optional = true }
4543
serde = { version = "1.0", optional = true }

rinja/src/filters/humansize.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use std::convert::Infallible;
22
use std::fmt;
33

4+
/// Trait to convert a `Copy` item into `f32`.
45
pub trait ToF32: Copy {
6+
/// Converting `self` into `f32`.
57
fn to_f32(self) -> f32;
68
}
79

rinja/src/filters/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
mod builtin;
1414
mod escape;
15-
#[cfg(feature = "humansize")]
1615
mod humansize;
1716
#[cfg(feature = "serde_json")]
1817
mod json;
@@ -27,8 +26,7 @@ pub use self::escape::{
2726
AutoEscape, AutoEscaper, Escaper, FastWritable, Html, HtmlSafe, HtmlSafeOutput, MaybeSafe,
2827
Safe, Text, Unsafe, Writable, WriteWritable, e, escape, safe,
2928
};
30-
#[cfg(feature = "humansize")]
31-
pub use self::humansize::filesizeformat;
29+
pub use self::humansize::{ToF32, filesizeformat};
3230
#[cfg(feature = "serde_json")]
3331
pub use self::json::{AsIndent, json, json_pretty};
3432
#[cfg(feature = "urlencode")]

rinja_actix/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["rinja/default"]
2424
full = ["rinja/full"]
2525
code-in-doc = ["rinja/code-in-doc"]
2626
config = ["rinja/config"]
27-
humansize = ["rinja/humansize"]
2827
serde_json = ["rinja/serde_json"]
2928
urlencode = ["rinja/urlencode"]
3029

rinja_axum/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["rinja/default"]
2424
full = ["rinja/full"]
2525
code-in-doc = ["rinja/code-in-doc"]
2626
config = ["rinja/config"]
27-
humansize = ["rinja/humansize"]
2827
serde_json = ["rinja/serde_json"]
2928
urlencode = ["rinja/urlencode"]
3029

rinja_derive/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ proc-macro = true
2020
[features]
2121
code-in-doc = ["dep:pulldown-cmark"]
2222
config = ["dep:serde", "dep:basic-toml", "parser/config"]
23-
humansize = []
2423
urlencode = []
2524
serde_json = []
2625
with-actix-web = []

rinja_derive/src/generator.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,18 +1657,11 @@ impl<'a> Generator<'a> {
16571657
buf: &mut Buffer,
16581658
name: &str,
16591659
args: &[WithSpan<'_, Expr<'_>>],
1660-
node: &WithSpan<'_, T>,
1660+
_node: &WithSpan<'_, T>,
16611661
) -> Result<DisplayWrap, CompileError> {
1662-
if cfg!(not(feature = "humansize")) {
1663-
return Err(ctx.generate_error(
1664-
&format!("the `{name}` filter requires the `humansize` feature to be enabled"),
1665-
node,
1666-
));
1667-
}
1668-
16691662
// All filters return numbers, and any default formatted number is HTML safe.
16701663
buf.write(format_args!(
1671-
"rinja::filters::HtmlSafeOutput(rinja::filters::{name}(",
1664+
"rinja::filters::HtmlSafeOutput(rinja::filters::{name}("
16721665
));
16731666
self._visit_args(ctx, buf, args)?;
16741667
buf.write(")?)");

rinja_derive_standalone/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ __standalone = []
2323

2424
code-in-doc = ["dep:pulldown-cmark"]
2525
config = ["dep:serde", "dep:basic-toml", "parser/config"]
26-
humansize = []
2726
urlencode = []
2827
serde_json = []
2928
with-actix-web = []

rinja_rocket/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["rinja/default"]
2424
full = ["rinja/full"]
2525
code-in-doc = ["rinja/code-in-doc"]
2626
config = ["rinja/config"]
27-
humansize = ["rinja/humansize"]
2827
serde_json = ["rinja/serde_json"]
2928
urlencode = ["rinja/urlencode"]
3029

rinja_warp/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["rinja/default"]
2424
full = ["rinja/full"]
2525
code-in-doc = ["rinja/code-in-doc"]
2626
config = ["rinja/config"]
27-
humansize = ["rinja/humansize"]
2827
serde_json = ["rinja/serde_json"]
2928
urlencode = ["rinja/urlencode"]
3029

0 commit comments

Comments
 (0)