commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
ec59921b855b9eb4cb20f0e086182b20a96e8fd0 | LeopoldArkham | 2016-11-19T22:38:08 | Added doc | diff --git a/Cargo.toml b/Cargo.toml
index 4d41a33..a82dbc1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Leopold Arkham <leopold.arkham@gmail.com>"]
description = "A crate to easily represent file sizes in a human-readable format."
repository = "https://github.com/LeopoldArk... | 1 | 1 | 0 |
b40d1a4cea68a569ccedd2e73392677a6b5bd9bf | LeopoldArkham | 2016-11-19T22:19:23 | Changed keywords | diff --git a/Cargo.toml b/Cargo.toml
index a68dd04..beba03c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,6 @@ version = "0.1.0"
authors = ["Leopold Arkham <leopold.arkham@gmail.com>"]
description = "A crate to easily represent file sizes in a human-readable format."
repository = "https://github.com/LeopoldArk... | 1 | 1 | 1 |
02f62ed1df6c2b7813cb098985337ae79c8343a6 | LeopoldArkham | 2016-11-19T22:15:50 | Added main function in example code to make it compile | diff --git a/src/lib.rs b/src/lib.rs
index 6ed1a0e..ba24ce1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,13 +17,15 @@
//! ```rust
//! extern crate humansize;
//! use humansize::{FileSize, file_size_opts as options};
-//!
-//! let size = 1000;
-//! println!("Size is {}", size.file_size(options::DECIMAL).unwrap());... | 1 | 9 | 7 |
8f95babfb829d6a4ec9b99e5056ccf99806d0092 | LeopoldArkham | 2016-11-19T22:15:29 | Better example | diff --git a/examples/custom_options.rs b/examples/custom_options.rs
index a96039a..0071ea3 100644
--- a/examples/custom_options.rs
+++ b/examples/custom_options.rs
@@ -15,7 +15,7 @@ fn main() {
// Or use only some custom parameters and adopt the rest from an existing config
- let semi_custom_options = opts::File... | 1 | 2 | 2 |
687fed7b4e49de78a12399f8bdb349eeb75a3f5e | LeopoldArkham | 2016-11-19T22:09:54 | Cleaned up | diff --git a/examples/sizes.rs b/examples/sizes.rs
index 4f3897f..076d115 100644
--- a/examples/sizes.rs
+++ b/examples/sizes.rs
@@ -1,11 +1,13 @@
-extern crate humanize;
-use std::str;
-use humanize::file_sizes::{FileSize, file_size_opts};
+extern crate humansize;
+//Import the trait and the options module
+use humans... | 1 | 7 | 5 |
4b1405d540e7951d9d39c1c9818d398b1f7260a7 | LeopoldArkham | 2016-11-19T22:09:39 | Moved file_sizes.rs here | diff --git a/src/lib.rs b/src/lib.rs
index cdfbe1a..6ed1a0e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,180 @@
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {
+//! # **Humansize**
+//!
+//! Humansize lets you easily represent file sizes in a human-friendly format.
+//! You can specify your own form... | 1 | 178 | 4 |
d1d0ccf396d7fa522c7d7ecd917f8de70d5a0fd5 | LeopoldArkham | 2016-11-19T22:08:52 | Added example for a custom option set | diff --git a/examples/custom_options.rs b/examples/custom_options.rs
new file mode 100644
index 0000000..a96039a
--- /dev/null
+++ b/examples/custom_options.rs
@@ -0,0 +1,21 @@
+extern crate humansize;
+use humansize::{FileSize, file_size_opts as opts};
+
+fn main() {
+ // Declare a fully custom option struct
+ let cus... | 1 | 21 | 0 |
df550f1fada900975fb05532edca63eae70a998c | LeopoldArkham | 2016-11-19T22:08:23 | Added keywords | diff --git a/Cargo.toml b/Cargo.toml
index 62958a2..a68dd04 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,9 @@
[package]
name = "humansize"
version = "0.1.0"
-authors = ["LeopoldArkham <leopold.arkham@gmail.com>"]
+authors = ["Leopold Arkham <leopold.arkham@gmail.com>"]
+description = "A crate to easily repres... | 1 | 4 | 1 |
148c2b8d6cd178ea1ec7b57d3e853c87637905c6 | Vincent Prouillet | 2026-03-03T08:35:08 | Introspection (#99) | diff --git a/tera/src/components.rs b/tera/src/components.rs
new file mode 100644
index 0000000..4af78b3
--- /dev/null
+++ b/tera/src/components.rs
@@ -0,0 +1,127 @@
+use std::collections::{BTreeMap, HashMap};
+use std::fmt;
+
+use crate::parsing::ast::{ComponentDefinition, Type};
+use crate::value::Value;
+
+/// The t... | 7 | 359 | 29 |
83b650cef33d54d3cb05af3a091923c8925c7f09 | Vincent Prouillet | 2026-02-19T19:44:32 | Actually use is_safe from function/filters (#101)
Closes #100 | diff --git a/tera/src/filters.rs b/tera/src/filters.rs
index 82f73d6..3245251 100644
--- a/tera/src/filters.rs
+++ b/tera/src/filters.rs
@@ -37,11 +37,16 @@ where
type FilterFunc = dyn Fn(&Value, Kwargs, &State) -> TeraResult<Value> + Sync + Send + 'static;
#[derive(Clone)]
-pub(crate) struct StoredFilter(Arc<Filte... | 5 | 108 | 10 |
a7949c007f2517c1877dce9ef49f27650812d27b | Vincent Prouillet | 2026-02-09T11:12:08 | Some perf improvements (#98) | diff --git a/tera/src/args.rs b/tera/src/args.rs
index 312bc4c..dbff5e7 100644
--- a/tera/src/args.rs
+++ b/tera/src/args.rs
@@ -33,7 +33,11 @@ macro_rules! impl_for_literal {
impl<'k> ArgFromValue<'k> for $ty {
type Output = Self;
fn from_value(value: &Value) -> Result<Self, Error> {... | 4 | 29 | 24 |
18f64fc08febe3e2341b6c30d392c3dd969a2566 | Vincent Prouillet | 2026-01-28T20:58:29 | Take into account line number size for padding of diag | diff --git a/tera/src/reporting.rs b/tera/src/reporting.rs
index a14d982..77f9bf7 100644
--- a/tera/src/reporting.rs
+++ b/tera/src/reporting.rs
@@ -53,13 +53,15 @@ impl<'a> SourceLocation<'a> {
pub(crate) fn generate_report(error: &ReportError) -> String {
let loc = SourceLocation::new(&error.source, &error.sp... | 1 | 9 | 7 |
b02e028819e66cae2e8d6fc7b9c44808a3842d83 | Vincent Prouillet | 2026-01-27T22:04:57 | Properly validate render_str tpls | diff --git a/tera/src/snapshot_tests/rendering.rs b/tera/src/snapshot_tests/rendering.rs
index ab7ddd5..e4394f2 100644
--- a/tera/src/snapshot_tests/rendering.rs
+++ b/tera/src/snapshot_tests/rendering.rs
@@ -303,3 +303,25 @@ Age: << age >>
let normalized_out = normalize_line_endings(&out);
insta::assert_snap... | 2 | 122 | 78 |
b61427829a9304303de200aaaaab3c1d82b0c16a | Vincent Prouillet | 2026-01-23T19:01:48 | Fix doc tests | diff --git a/tera/src/tera.rs b/tera/src/tera.rs
index 0cf1603..f5fa1e0 100644
--- a/tera/src/tera.rs
+++ b/tera/src/tera.rs
@@ -181,12 +181,19 @@ impl Tera {
///
/// ```
/// # use tera::{Tera, Context};
+ /// # use std::io::Write;
/// // Create new Tera instance
/// let mut tera = Tera::def... | 1 | 52 | 22 |
4e79990d3922f3be66c5ba0c106dea8c6d51eb81 | Vincent Prouillet | 2026-01-23T18:56:00 | Make Tera::render_str not need &mut | diff --git a/tera/src/tera.rs b/tera/src/tera.rs
index 3676c7a..0cf1603 100644
--- a/tera/src/tera.rs
+++ b/tera/src/tera.rs
@@ -813,11 +813,12 @@ impl Tera {
/// which is useful for sharing common data
///
/// ```
+ /// # use tera::{Tera, Context, context};
/// let mut tera = Tera::new();
/... | 2 | 130 | 28 |
fa497c9400ad9461178335dad913c38a89170fe9 | Vincent Prouillet | 2026-01-22T19:39:42 | u128/i128 keys and handle error when serializing | diff --git a/tera/src/context.rs b/tera/src/context.rs
index a15a6d3..83a95ca 100644
--- a/tera/src/context.rs
+++ b/tera/src/context.rs
@@ -37,6 +37,8 @@ impl Context {
Key::Bool(b) => Cow::Owned(b.to_string()),
Key::U64(u) => Cow::Owned(u.to_string()),
... | 5 | 425 | 22 |
13c376cc0fa975b44335c56fa867cd7f6ae3b0c3 | Vincent Prouillet | 2026-01-19T20:48:14 | More idiomatic get_template | diff --git a/tera/src/tera.rs b/tera/src/tera.rs
index 1565b4d..3676c7a 100644
--- a/tera/src/tera.rs
+++ b/tera/src/tera.rs
@@ -490,7 +490,7 @@ impl Tera {
let mut all_blocks = vec![chunk.clone()];
if chunk.is_calling_function("super") {
for parent_tpl_name in tpl... | 2 | 16 | 11 |
899fec2d7499b8847af553a115a580b0d87716a3 | Vincent Prouillet | 2026-01-19T15:41:53 | Error on block lineage being empty
Doesn't happen on normal usecase but can happen
if users ignore the error when adding a template and
then it could panic | diff --git a/tera/src/vm/interpreter.rs b/tera/src/vm/interpreter.rs
index 9a2c6b2..80d9d17 100644
--- a/tera/src/vm/interpreter.rs
+++ b/tera/src/vm/interpreter.rs
@@ -451,6 +451,13 @@ impl<'tera> VirtualMachine<'tera> {
.get(block_name)
.map(|bl| bl.iter().collect())
... | 1 | 7 | 0 |
a515f34a71029ff2a22e0ef4adc78707cea6f70a | Vincent Prouillet | 2026-01-19T15:41:36 | Secretly expose load_from_glob | diff --git a/tera/src/globbing.rs b/tera/src/globbing.rs
index c106ada..f17aca7 100644
--- a/tera/src/globbing.rs
+++ b/tera/src/globbing.rs
@@ -7,7 +7,7 @@ use crate::errors::{Error, TeraResult};
/// Loads the glob and find all files matching that glob,
/// returning a list of (path, filename)
-pub(crate) fn load_... | 2 | 5 | 1 |
5a3b9d82f8e52c872724e7bfcea538798dc030eb | Vincent Prouillet | 2026-01-19T13:35:30 | More date filters/functions (#95) | diff --git a/tera-contrib/src/dates.rs b/tera-contrib/src/dates.rs
index 45cab08..1833a92 100644
--- a/tera-contrib/src/dates.rs
+++ b/tera-contrib/src/dates.rs
@@ -5,81 +5,89 @@ use tera::{Kwargs, Number, State, TeraResult, Value};
static PARSER: DateTimeParser = DateTimeParser::new();
-pub fn now(kwargs: Kwargs,... | 1 | 167 | 63 |
4dbaeb8225c7e802cc7f8ce4d94acadf7b0f259c | Vincent Prouillet | 2026-01-19T13:14:21 | Add escape_xml | diff --git a/tera/src/filters.rs b/tera/src/filters.rs
index 9974a16..113b5d2 100644
--- a/tera/src/filters.rs
+++ b/tera/src/filters.rs
@@ -96,6 +96,21 @@ pub(crate) fn escape(val: &str, _: Kwargs, _: &State) -> String {
unsafe { String::from_utf8_unchecked(buf) }
}
+pub(crate) fn escape_xml(val: &str, _: Kwar... | 2 | 33 | 0 |
4f220755a307127f6d7aa27fc52f22e210e5de75 | Vincent Prouillet | 2026-01-19T10:30:17 | Handle priority with fallback rather than from_extend | diff --git a/tera/src/template.rs b/tera/src/template.rs
index 6691956..a451160 100644
--- a/tera/src/template.rs
+++ b/tera/src/template.rs
@@ -27,9 +27,6 @@ pub struct Template {
/// The full list of parent templates names
pub(crate) parents: Vec<String>,
pub(crate) block_lineage: HashMap<String, Vec<C... | 2 | 132 | 175 |
2da1834de537f4e17112fd980c030a54bf0f63b6 | Vincent Prouillet | 2026-01-18T14:58:40 | Add fallback_prefixes | diff --git a/tera/src/template.rs b/tera/src/template.rs
index 12db96b..6691956 100644
--- a/tera/src/template.rs
+++ b/tera/src/template.rs
@@ -2,6 +2,7 @@ use crate::delimiters::Delimiters;
use crate::errors::{Error, ErrorKind, TeraResult};
use crate::parsing::ast::ComponentDefinition;
use crate::parsing::{Chunk, ... | 2 | 101 | 25 |
0800db90777e2ed02ba12a6e68d66122ccbb8780 | Vincent Prouillet | 2026-01-18T13:58:26 | Add better state.get | diff --git a/tera/src/snapshot_tests/rendering.rs b/tera/src/snapshot_tests/rendering.rs
index 3a18b3f..ab7ddd5 100644
--- a/tera/src/snapshot_tests/rendering.rs
+++ b/tera/src/snapshot_tests/rendering.rs
@@ -134,8 +134,14 @@ fn rendering_ok() {
let mut tera = Tera::default();
tera.autoescape_on(vec![... | 3 | 26 | 12 |
d14afc2d553d5a0622814ed2eea82055f51738fe | Vincent Prouillet | 2026-01-18T13:43:27 | Add register test + cow support | diff --git a/tera-contrib/src/base64.rs b/tera-contrib/src/base64.rs
index 3d69e7c..1592667 100644
--- a/tera-contrib/src/base64.rs
+++ b/tera-contrib/src/base64.rs
@@ -88,4 +88,11 @@ mod tests {
let result = b64_decode("not valid base64!!!", Kwargs::default(), &state);
assert!(result.is_err());
... | 9 | 66 | 5 |
88fa4dcf670125c24b6ed65d5eb334511fd8fdfe | Vincent Prouillet | 2026-01-17T22:31:22 | Simpler Kwargs setup for tests | diff --git a/tera/src/args.rs b/tera/src/args.rs
index 0c1f585..7b9bb0d 100644
--- a/tera/src/args.rs
+++ b/tera/src/args.rs
@@ -204,6 +204,16 @@ impl Kwargs {
}
}
+impl<const N: usize> From<[(&'static str, Value); N]> for Kwargs {
+ fn from(pairs: [(&'static str, Value); N]) -> Self {
+ let mut map =... | 2 | 14 | 12 |
9691930d5d3e2b25644d741e99850f8d6e5a1f1a | Vincent Prouillet | 2026-01-16T23:39:31 | Make is_number pub | diff --git a/tera/src/value/mod.rs b/tera/src/value/mod.rs
index aed748c..063c4ef 100644
--- a/tera/src/value/mod.rs
+++ b/tera/src/value/mod.rs
@@ -492,7 +492,7 @@ impl Value {
}
}
- pub(crate) fn is_number(&self) -> bool {
+ pub fn is_number(&self) -> bool {
matches!(
&self... | 1 | 1 | 1 |
8f98c4f01658048f58db2fbfb78470f54f4c9c5a | Vincent Prouillet | 2026-01-16T20:15:52 | Impl Debug for Tera | diff --git a/tera/src/tera.rs b/tera/src/tera.rs
index 6ebb080..229c0f6 100644
--- a/tera/src/tera.rs
+++ b/tera/src/tera.rs
@@ -1,3 +1,4 @@
+use std::fmt;
use std::fs::File;
use std::io::{Read, Write};
use std::path::Path;
@@ -952,6 +953,21 @@ impl Default for Tera {
}
}
+impl fmt::Debug for Tera {
+ fn ... | 1 | 16 | 0 |
be4aff115e354735af2c8f60e2abfab5ec6096a2 | Vincent Prouillet | 2026-01-15T13:33:22 | Simpler spread handling in vm | diff --git a/tera/src/vm/interpreter.rs b/tera/src/vm/interpreter.rs
index a0f6f8a..ce5b4c1 100644
--- a/tera/src/vm/interpreter.rs
+++ b/tera/src/vm/interpreter.rs
@@ -301,8 +301,10 @@ impl<'tera> VirtualMachine<'tera> {
state.stack.push(Value::from(map), None)
}
... | 1 | 13 | 28 |
6cb7da644d5b5662a67ac0d82910c9e00d254ba7 | Vincent Prouillet | 2026-01-15T13:26:40 | Reuse buffer for escaping | diff --git a/tera/src/vm/interpreter.rs b/tera/src/vm/interpreter.rs
index cacb595..a0f6f8a 100644
--- a/tera/src/vm/interpreter.rs
+++ b/tera/src/vm/interpreter.rs
@@ -261,12 +261,12 @@ impl<'tera> VirtualMachine<'tera> {
}
} else {
// Avoiding Str... | 2 | 11 | 8 |
31c71cb065b416c5552c3c903584a868ce58ba11 | Vincent Prouillet | 2026-01-15T10:21:43 | Merge opt and non opt branch for vm | diff --git a/tera/src/vm/interpreter.rs b/tera/src/vm/interpreter.rs
index 2963b5c..cacb595 100644
--- a/tera/src/vm/interpreter.rs
+++ b/tera/src/vm/interpreter.rs
@@ -158,67 +158,44 @@ impl<'tera> VirtualMachine<'tera> {
state.stack.push(v.clone(), Some(current_ip..=current_ip));
... | 1 | 27 | 62 |
2f08e6fad68465508f616c9f1258eaf8f8bfb0be | Vincent Prouillet | 2026-01-13T22:40:41 | Add regex_replace filter | diff --git a/tera-contrib/src/base64.rs b/tera-contrib/src/base64.rs
index 8feb52c..3d69e7c 100644
--- a/tera-contrib/src/base64.rs
+++ b/tera-contrib/src/base64.rs
@@ -1,4 +1,4 @@
-use base64::{engine::general_purpose, Engine};
+use base64::{Engine, engine::general_purpose};
use tera::{Kwargs, State, TeraResult};
... | 2 | 84 | 28 |
e86c6d7335ecc23cb6555bec23df57dbb0f3cd94 | Vincent Prouillet | 2026-01-13T22:30:32 | b64 in tera-contrib | diff --git a/Cargo.lock b/Cargo.lock
index 151f32b..4a9909a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -52,6 +52,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+[[package]]
+name = "base64"
+vers... | 5 | 112 | 4 |
281ce8c1b041f09559e161376e3dec9d7232bdc2 | Vincent Prouillet | 2026-01-13T22:30:22 | Some pub things | diff --git a/tera/src/lib.rs b/tera/src/lib.rs
index d167751..3ded339 100644
--- a/tera/src/lib.rs
+++ b/tera/src/lib.rs
@@ -21,11 +21,12 @@ pub use context::Context;
pub use delimiters::Delimiters;
pub use errors::{Error, ErrorKind, TeraResult};
pub use filters::Filter;
+pub use functions::Function;
pub use parsin... | 2 | 3 | 2 |
90b59d2f93451c9bb9ade855f05887e10eff6e7f | Vincent Prouillet | 2026-01-13T07:57:10 | Add Context::from_serialize (#93)
Closes #92 | diff --git a/tera/src/context.rs b/tera/src/context.rs
index d342ae5..a15a6d3 100644
--- a/tera/src/context.rs
+++ b/tera/src/context.rs
@@ -3,7 +3,7 @@ use std::collections::BTreeMap;
use serde::Serialize;
-use crate::value::Value;
+use crate::value::{Key, Value};
/// The struct that holds the context of a tem... | 1 | 57 | 1 |
867f68878c1b7b3148ce1cd2c8487ef19e946fb7 | Vincent Prouillet | 2026-01-10T21:36:06 | Fix clippy | diff --git a/tera/benches/escape.rs b/tera/benches/escape.rs
index 7358890..63a3701 100644
--- a/tera/benches/escape.rs
+++ b/tera/benches/escape.rs
@@ -1,4 +1,6 @@
-use criterion::{Criterion, black_box, criterion_group, criterion_main};
+use std::hint::black_box;
+
+use criterion::{Criterion, criterion_group, criterio... | 3 | 8 | 3 |
9746315a89d5e816c2c81a9b90beb1c36e94960a | Vincent Prouillet | 2026-01-10T20:05:06 | Update deps | diff --git a/Cargo.lock b/Cargo.lock
index dbe6db0..151f32b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -25,6 +25,15 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "alloca"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5a7d05ea6aea7e9e64d25b9156ba2fee3fdd6... | 3 | 113 | 68 |
0dc2944e6fac81e76465e970f683f1749fbf59c6 | Vincent Prouillet | 2025-12-04T11:03:27 | Fix str concat TODO in VM (#81) | diff --git a/tera/src/vm/interpreter.rs b/tera/src/vm/interpreter.rs
index 0b0703c..6c18dbb 100644
--- a/tera/src/vm/interpreter.rs
+++ b/tera/src/vm/interpreter.rs
@@ -4,7 +4,7 @@ use std::io::Write;
use crate::errors::{Error, ErrorKind, ReportError, TeraResult};
use crate::parsing::{Chunk, Instruction};
use crate:... | 1 | 12 | 3 |
91eb5e373be24aacf4c89556e2aa0ef6bc1aa280 | Vincent Prouillet | 2025-07-18T12:42:43 | Fix date filters | diff --git a/tera-contrib/src/dates.rs b/tera-contrib/src/dates.rs
index 43efa18..b0dc0ce 100644
--- a/tera-contrib/src/dates.rs
+++ b/tera-contrib/src/dates.rs
@@ -1,7 +1,7 @@
use jiff::fmt::temporal::DateTimeParser;
use jiff::tz::TimeZone;
use jiff::{Timestamp, Zoned};
-use tera::{Kwargs, State, TeraResult, Value}... | 1 | 21 | 19 |
f86b3c1e4461eef3e219e6afcb5cd2d60b643178 | Vincent Prouillet | 2025-06-16T10:38:48 | Simplify for loops | diff --git a/tera/src/value/mod.rs b/tera/src/value/mod.rs
index c7d9d3c..f5814c6 100644
--- a/tera/src/value/mod.rs
+++ b/tera/src/value/mod.rs
@@ -634,7 +634,6 @@ impl Value {
)
}
-
pub(crate) fn as_key(&self) -> TeraResult<Key<'static>> {
let key = match &self.inner {
Value... | 2 | 89 | 117 |
0ab2ed9fd4386f39530be4bf3eda22ec583ed16a | Vincent Prouillet | 2025-06-10T10:02:08 | Improved for loop perf | diff --git a/Cargo.toml b/Cargo.toml
index 45e42a8..db05919 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,3 +1,6 @@
[workspace]
members = ["tera", "tera-contrib"]
-resolver = "2"
\ No newline at end of file
+resolver = "2"
+
+[profile.release]
+debug = true
\ No newline at end of file
diff --git a/tera/examples/big_... | 5 | 227 | 92 |
dae752912f845ac06a89368eaaca1d6f9edcfa3b | Vincent Prouillet | 2025-06-09T23:14:12 | Some inlining | diff --git a/tera/src/vm/for_loop.rs b/tera/src/vm/for_loop.rs
index e30238d..eaf7dec 100644
--- a/tera/src/vm/for_loop.rs
+++ b/tera/src/vm/for_loop.rs
@@ -65,6 +65,7 @@ struct Loop {
}
impl Loop {
+ #[inline(always)]
fn advance(&mut self) {
self.index += 1;
self.index0 += 1;
@@ -151,6 +1... | 1 | 3 | 0 |
089924e638782f55a760c9d6e0def858e9f2fc58 | Vincent Prouillet | 2025-06-09T23:02:45 | Use Cow<static, str> for context keys | diff --git a/tera/src/context.rs b/tera/src/context.rs
index afe6b05..5a9256e 100644
--- a/tera/src/context.rs
+++ b/tera/src/context.rs
@@ -1,3 +1,4 @@
+use std::borrow::Cow;
use std::collections::BTreeMap;
use serde::Serialize;
@@ -10,8 +11,7 @@ use crate::value::Value;
/// values
#[derive(Debug, Clone, Partial... | 4 | 19 | 7 |
d175161841e916a39e2e689b0f4e2113bf62c10d | Vincent Prouillet | 2024-09-24T14:38:22 | clean up | diff --git a/tera/src/vm/state.rs b/tera/src/vm/state.rs
index a3e8153..deb695b 100644
--- a/tera/src/vm/state.rs
+++ b/tera/src/vm/state.rs
@@ -108,39 +108,6 @@ impl<'t> State<'t> {
}
}
- // pub fn current_context_cloned(&self) -> Value {
- // let mut context = HashMap::new();
- //
- //... | 1 | 0 | 33 |
180f357c6f74a9dcad5d54ad6004b4d01dc3b279 | Allan | 2024-09-05T08:20:04 | Make `Error` and `ErrorKind` public (#48) | diff --git a/tera/src/lib.rs b/tera/src/lib.rs
index f932e46..b6830a2 100644
--- a/tera/src/lib.rs
+++ b/tera/src/lib.rs
@@ -17,7 +17,7 @@ pub(crate) mod vm;
pub use crate::tera::{EscapeFn, Tera};
pub use args::Kwargs;
pub use context::Context;
-pub use errors::TeraResult;
+pub use errors::{Error, ErrorKind, TeraRes... | 1 | 1 | 1 |
f2b65b3ae5395e7eaa9aa759302375e7907ce949 | Vincent Prouillet | 2024-09-01T21:20:59 | Remove ryu float fmt (#47) | diff --git a/Cargo.lock b/Cargo.lock
index 3ef884a..0844c5f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -688,7 +688,6 @@ dependencies = [
"insta",
"itoa",
"pulldown-cmark-escape",
- "ryu",
"serde",
"serde_derive",
"tempfile",
diff --git a/tera/Cargo.toml b/tera/Cargo.toml
index 2a73a6f..f4b4212 100644
--- a... | 3 | 4 | 10 |
bab89ae42f2a4c89a38fa45f2f5161f5f55c5f97 | Vincent Prouillet | 2024-09-01T21:04:02 | Add Tera::extend (#46) | diff --git a/tera/src/template.rs b/tera/src/template.rs
index 93e03d3..1f1c076 100644
--- a/tera/src/template.rs
+++ b/tera/src/template.rs
@@ -23,6 +23,9 @@ pub struct Template {
/// The full list of parent templates names
pub(crate) parents: Vec<String>,
pub(crate) block_lineage: HashMap<String, Vec<C... | 2 | 126 | 1 |
f1bccd538cdf4227843ef00b8bbc44e774563531 | Vincent Prouillet | 2024-08-27T21:59:02 | Clean warnings (#44)
* wip
* Enum deser
* Clippy
* Typo + error handling | diff --git a/Cargo.lock b/Cargo.lock
index 4eb97eb..b26426a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -37,9 +37,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstyle"
-version = "1.0.7"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/cra... | 18 | 310 | 252 |
167d030de6830beb3e312e83ce406fd95dd92f35 | Vincent Prouillet | 2024-08-26T10:36:46 | Add back Tera::render_to (#43) | diff --git a/tera/src/tera.rs b/tera/src/tera.rs
index 1648159..75c8d2b 100644
--- a/tera/src/tera.rs
+++ b/tera/src/tera.rs
@@ -7,6 +7,7 @@ use crate::tests::{StoredTest, Test, TestResult};
use crate::value::FunctionResult;
use crate::vm::interpreter::VirtualMachine;
use crate::{escape_html, Context, HashMap};
+use... | 3 | 62 | 3 |
a56189b14cfcda296340a22d273a4bbe1d1c52b0 | Filip Chovanec | 2024-01-02T13:51:17 | Add global contexts (#25) | diff --git a/src/tera.rs b/src/tera.rs
index 1e9b468..16f1885 100644
--- a/src/tera.rs
+++ b/src/tera.rs
@@ -19,6 +19,7 @@ pub struct Tera {
autoescape_suffixes: Vec<&'static str>,
#[doc(hidden)]
escape_fn: EscapeFn,
+ global_context: Context,
}
impl Tera {
@@ -276,7 +277,37 @@ impl Tera {
pu... | 1 | 59 | 1 |
14cc823b0c33f25581ba45770fd69a861cc90c86 | Filip Chovanec | 2023-12-27T21:13:55 | Add context! macro for building Contexts (#24) | diff --git a/src/context.rs b/src/context.rs
index ef59db4..d4d8eba 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -58,3 +58,57 @@ impl Context {
self.data.append(&mut source.data);
}
}
+
+/// Creates a context from key value pairs
+///
+/// Example:
+/// ```rust
+/// let ctx = context! {
+/// n... | 1 | 54 | 0 |
9d2dc18d8ac36bf1b0f033eedaeb98f2c4431566 | Vincent Prouillet | 2023-11-27T21:50:20 | Finish key impl + fix fuzzing (#20) | diff --git a/benches/iai-escape.rs b/benches/iai-escape.rs
index f3526b3..d88c8f1 100644
--- a/benches/iai-escape.rs
+++ b/benches/iai-escape.rs
@@ -1,8 +1,8 @@
use std::hint::black_box;
-use iai_callgrind::main;
use iai_callgrind::library_benchmark;
use iai_callgrind::library_benchmark_group;
+use iai_callgrind::... | 10 | 67 | 67 |
969996db70f1ec31a7a19e71bcf3bcdb1f2205c5 | Vincent Prouillet | 2023-11-27T21:04:43 | Remove some unused stuff | diff --git a/Cargo.toml b/Cargo.toml
index 8eb0c2b..e3f1f66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,7 @@ default = []
ahash = ["hashbrown", "hashbrown/serde"]
# Keep order of insertion for Value
preserve_order = ["dep:indexmap"]
-# If we want Tera to work with graphemes clusters rather than utf-8 chara... | 6 | 1 | 15 |
225742cdf477398f93023749f70530aebe777616 | Jalil David Salamé Messina | 2023-11-27T21:00:18 | feat: Avoid std::fmt machinery where possible (#19)
* feat(VirtualMachine::interpret): Avoid std::fmt machinery
* feat: Feature gate perf improvements that require extra deps | diff --git a/Cargo.lock b/Cargo.lock
index 5484188..89b253d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -679,6 +679,8 @@ dependencies = [
"iai-callgrind",
"indexmap",
"insta",
+ "itoa",
+ "ryu",
"serde",
"serde_derive",
"unic-segment",
diff --git a/Cargo.toml b/Cargo.toml
index a18f19b..8eb0c2b 100644
--- a... | 5 | 140 | 9 |
8518b1b2c4b01d735b265ad1e49454d27600db96 | Vincent Prouillet | 2023-11-26T07:48:03 | comment out iai | diff --git a/Cargo.toml b/Cargo.toml
index 48ce715..a18f19b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,14 +41,16 @@ harness = false
name = "templates"
harness = false
-[[bench]]
-name = "iai-value"
-harness = false
-
-[[bench]]
-name = "iai-escape"
-harness = false
-
-[[bench]]
-name = "iai-templates"
-harness... | 1 | 13 | 11 |
060281fbe18f191054ebd0f53301fc232b8b48f6 | Jalil David Salamé Messina | 2023-11-25T19:15:54 | feat(benches): Add iai benchmarks (#15)
* feat(benches): Add iai benchmarks
iai uses valgrind to get perf counters from the cpu making jitter less
of an issue. You need to have valgrind installed to run the benchmarks
though.
* chore: Update to iai-callgrind 0.8.0 | diff --git a/Cargo.lock b/Cargo.lock
index 09aca5a..5484188 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -47,6 +47,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+[[package]]
+name = "bincode"
+ver... | 5 | 421 | 4 |
df468411dfee7a9ba509ef5a654dfa62b18999d8 | Vincent Prouillet | 2023-11-01T22:16:48 | Tweaks to cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 96bd507..c52925f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,17 +6,15 @@ edition = "2021"
[dependencies]
serde = "1"
-# And optional ones
+# Optional deps
indexmap = { version = "2", optional = true }
hashbrown = { version = "0.14", optional = true }
[features]
-de... | 2 | 4 | 6 |
30c4b864ecd9e24e071e0e7203a6986adb4ce3b2 | Vincent Prouillet | 2023-11-01T21:33:54 | Remove some todos | diff --git a/src/value/key.rs b/src/value/key.rs
index f1ab697..aa80fa8 100644
--- a/src/value/key.rs
+++ b/src/value/key.rs
@@ -133,11 +133,11 @@ impl Serializer for KeySerializer {
}
fn serialize_f32(self, _v: f32) -> Result<Self::Ok, Self::Error> {
- todo!()
+ Err(SerializationFailed)
... | 4 | 16 | 20 |
6f68f74352efb2998cc2e9c331f30ab336cf22c1 | Vincent Prouillet | 2023-10-31T13:30:15 | Added test for self inheritance | diff --git a/tests/inheritance.rs b/tests/inheritance.rs
index 63d1b07..0248086 100644
--- a/tests/inheritance.rs
+++ b/tests/inheritance.rs
@@ -197,3 +197,15 @@ fn render_super_in_grandchild_without_redefining_in_parent_works() {
let result = tera.render("child", &Context::new());
assert_eq!(result.unwrap(),... | 1 | 12 | 0 |
85bacad91524e74a82328648ff6b47f226063c14 | Jalil David Salamé Messina | 2023-10-28T12:37:00 | feat: Switch to hashbrown::Hash* (#13)
Uses AHash instead of SipHash which is faster.
11% imprvement to realistic.
Overall about 10% improvements
Tested FxHash, no noticeable improvements over AHash but it requires a
lot more changes (`HashMap::new` and `HashMap::with_capacity` are nto
available, you have t... | diff --git a/Cargo.lock b/Cargo.lock
index a6ca477..83a936d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,17 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "ahash"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c99f64d1e06488f62... | 12 | 59 | 22 |
2e40250a3465c433e2e0b9264a3989d32893f4f0 | Jalil David Salamé Messina | 2023-08-02T18:51:47 | feat: Rework impl Display for Value (#10)
escape_html_long: -1.95%
escape_html_short: -4.78%
serialization: -4.45%
No improvements/regressions elsewhere | diff --git a/src/value/mod.rs b/src/value/mod.rs
index 28e91f6..913bf29 100644
--- a/src/value/mod.rs
+++ b/src/value/mod.rs
@@ -63,34 +63,41 @@ impl fmt::Display for Value {
Value::U128(v) => write!(f, "{v}"),
Value::I128(v) => write!(f, "{v}"),
Value::Array(v) => {
+ ... | 1 | 21 | 14 |
f4066a6a284b9f4562347cae115c19eaf5530eda | Jalil David Salamé Messina | 2023-07-27T20:26:58 | fix: Change ForLoop.context to HashMap (#9)
* fix: Change ForLoop.context to HashMap
Improvements of 6% in big-table and mostly 1-2% in others
* fix: Simplify ForLoop::new
Mixed perf results +/-3%
* fix: Hoist error handling out of match statement
* feat: Change VecDeque to Vec in ForLoop
Using std::... | diff --git a/src/vm/for_loop.rs b/src/vm/for_loop.rs
index eae0c23..6857bfd 100644
--- a/src/vm/for_loop.rs
+++ b/src/vm/for_loop.rs
@@ -3,39 +3,48 @@ use crate::Value;
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
-use std::collections::{BTreeMap, VecDeque};
+use std::collections::HashMap;
... | 1 | 37 | 45 |
d3e7d1f0c1eaf538a3af7162a9b9c32e3f15be58 | Vincent Prouillet | 2023-07-09T19:06:01 | We do need HashMap anyway | diff --git a/src/value/mod.rs b/src/value/mod.rs
index fbfe5ad..ef68557 100644
--- a/src/value/mod.rs
+++ b/src/value/mod.rs
@@ -1,6 +1,5 @@
use std::borrow::Cow;
use std::cmp::Ordering;
-#[cfg(not(feature = "preserve_order"))]
use std::collections::HashMap;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt... | 1 | 0 | 1 |
683516f887a09b8280747467e1f540eef8b7c313 | Vincent Prouillet | 2021-07-25T17:17:35 | Refactor + criterion | diff --git a/Cargo.lock b/Cargo.lock
index 279b032..90758df 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,10 +1,79 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-l... | 9 | 697 | 124 |
7e18122a15f6b2e3452b5bc2bec68ebcadc1dcba | Vincent Prouillet | 2021-07-07T17:08:39 | Some more test cases | diff --git a/Cargo.lock b/Cargo.lock
index 8f050f5..279b032 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -57,9 +57,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.26"
+version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a152013215dca273577e18d2bf00... | 4 | 11 | 8 |
496ab88ca18cb68b76d80543a932bf1a0af2f499 | Vincent Prouillet | 2021-06-28T21:11:23 | Spanned expressions | diff --git a/Cargo.lock b/Cargo.lock
index 35ae1de..8f050f5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -52,6 +52,7 @@ version = "0.1.0"
dependencies = [
"codespan-reporting",
"logos",
+ "valuable",
]
[[package]]
@@ -116,6 +117,24 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-... | 8 | 401 | 89 |
bafa548e4937b1155bceb53d5c39dbb4d7b89fa3 | Vincent Prouillet | 2021-06-02T17:14:24 | Move things around | diff --git a/src/lib.rs b/src/lib.rs
index 20e5776..33a921e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,25 +1,5 @@
#![allow(dead_code)]
-use std::ops::Range;
-
-pub mod ast;
-mod errors;
-mod lexer;
pub mod parser;
-
-#[cfg(test)]
-mod tests;
-
pub use parser::Parser;
-
-#[derive(Clone, Debug, PartialEq)]
-pub ... | 9 | 32 | 31 |
a4cad11386c2df9075b9e1ddf33ce8cef69079c3 | Vincent Prouillet | 2021-06-01T17:58:58 | Add size hint | diff --git a/src/parser.rs b/src/parser.rs
index 7759c61..4aede2b 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -81,6 +81,8 @@ pub struct Parser<'a> {
pub macros: HashMap<String, MacroDefinition>,
// (file, namespace)
pub macro_imports: Vec<(String, String)>,
+ // The size in bytes of the text, no... | 1 | 6 | 3 |
0f40704213369f74e85a70c0998c84fe4e9d3049 | Vincent Prouillet | 2021-06-01T09:26:25 | Supports forloops | diff --git a/src/ast.rs b/src/ast.rs
index 58f33fe..eb5eae6 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -30,6 +30,14 @@ impl Expression {
_ => panic!("Called as_array on a non array value"),
}
}
+
+ pub(crate) fn can_be_iterated_on(&self) -> bool {
+ use Expression::*;
+ matc... | 5 | 217 | 18 |
127cae20e57cfd6d8a272d3f469d626aefd9f419 | Vincent Prouillet | 2021-05-31T20:21:10 | Supports macro | diff --git a/src/ast.rs b/src/ast.rs
index 97699f9..9b89654 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -7,8 +7,8 @@ use crate::lexer::Operator;
#[derive(Clone, Debug, PartialEq)]
#[allow(missing_docs)]
pub enum Expression {
- String(String),
- Int(i64),
+ Str(String),
+ Integer(i64),
Float(f64),
... | 4 | 186 | 26 |
09df102191254c747c1f13fbd10f9da1371e309f | Vincent Prouillet | 2021-05-31T15:13:08 | Supports filter sections | diff --git a/src/parser.rs b/src/parser.rs
index e730972..9cacdb2 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -101,6 +101,33 @@ impl<'a> Parser<'a> {
self.parse_content()
}
+ fn pop_filter_section(&mut self) -> ParsingResult<FilterSection> {
+ let mut nodes = vec![];
+ loop {
+ ... | 2 | 123 | 3 |
771df762476a7e1ff86d50ec4f9aaef428c71739 | Vincent Prouillet | 2021-05-30T16:34:42 | Handle nested extends | diff --git a/src/ast.rs b/src/ast.rs
index 1768dd0..97699f9 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -139,6 +139,15 @@ pub struct If {
pub otherwise: Vec<Node>,
}
+/// A filter section node `{{ filter name(param="value") }} content {{ endfilter }}`
+#[derive(Clone, Debug, PartialEq)]
+pub struct FilterSectio... | 5 | 322 | 159 |
40b5f09c7546f03ccbad08455f2f0f3661c77ea5 | Vincent Prouillet | 2021-05-28T18:34:39 | Supports raw tag | diff --git a/src/ast.rs b/src/ast.rs
index cc479b3..41a7b1b 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -125,8 +125,9 @@ pub struct Set {
#[derive(Clone, Debug, PartialEq)]
pub enum Node {
Text(String),
- Expression(Expression),
+ VariableBlock(Expression),
Set(Set),
+ Raw(String),
Include {
... | 5 | 74 | 5 |
0f92279d3e59b6ee4cf1073ba428b643e12fa3b4 | Vincent Prouillet | 2021-05-28T17:58:59 | Some more error handling | diff --git a/src/ast.rs b/src/ast.rs
index 232d0c6..cc479b3 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -127,7 +127,6 @@ pub enum Node {
Text(String),
Expression(Expression),
Set(Set),
- Extends(String),
Include {
files: Vec<String>,
ignore_missing: bool,
diff --git a/src/errors... | 5 | 36 | 20 |
0201af7bc969872104e937223e710d604b7dcc1f | Vincent Prouillet | 2021-05-28T07:24:47 | Some more text handling | diff --git a/src/lexer.rs b/src/lexer.rs
index a48f80a..744ea32 100644
--- a/src/lexer.rs
+++ b/src/lexer.rs
@@ -215,7 +215,6 @@ impl fmt::Display for Token {
}
}
-// TODO: inline those?
impl Token {
fn from_content(tok: Content) -> Self {
match tok {
@@ -422,7 +421,7 @@ impl<'source> PeekableLex... | 3 | 54 | 42 |
86369ecc9e05d4435a40943caf9757a0a8573679 | Vincent Prouillet | 2021-05-28T06:28:09 | Implement comments | diff --git a/benches/parsing.rs b/benches/parsing.rs
new file mode 100644
index 0000000..7e3402c
--- /dev/null
+++ b/benches/parsing.rs
@@ -0,0 +1,23 @@
+#![feature(test)]
+extern crate test;
+use parser_test::Parser;
+
+static SIMPLE_TEMPLATE: &'static str = "
+<html>
+ <head>
+ <title>{{ product.name }}</title>
+... | 4 | 107 | 5 |
da44817c403c6cc978e0b279a7e1cfb1686fd0a7 | Vincent Prouillet | 2021-05-28T05:34:55 | Implement include/extends | diff --git a/src/ast.rs b/src/ast.rs
index 85d0991..232d0c6 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -22,6 +22,15 @@ pub enum Expression {
Expr(Operator, Vec<Expression>),
}
+impl Expression {
+ pub(crate) fn as_array(self) -> Vec<Expression> {
+ match self {
+ Expression::Array(vals) =>... | 5 | 224 | 26 |
7bfc507dbb511b68e8468bde8b513b2307b39ca8 | Vincent Prouillet | 2021-05-27T21:12:22 | Implement set/set_global | diff --git a/src/ast.rs b/src/ast.rs
index 5639f94..85d0991 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -100,9 +100,22 @@ impl fmt::Display for Expression {
}
}
+/// Set a variable in the context `{% set val = "hey" %}`
+#[derive(Clone, Debug, PartialEq)]
+pub struct Set {
+ /// The name for that value in th... | 5 | 112 | 30 |
f7d5dc240136d1ce7c180895ad7a90e8110e0e57 | Vincent Prouillet | 2021-05-27T19:59:58 | Remove constant folding for now | diff --git a/src/ast.rs b/src/ast.rs
index bbb2e10..5639f94 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1,6 +1,5 @@
use std::collections::HashMap;
use std::fmt;
-use std::string::String as StdString;
use crate::lexer::Operator;
@@ -23,51 +22,12 @@ pub enum Expression {
Expr(Operator, Vec<Expression>),
}
... | 5 | 45 | 83 |
bf83155b64c205dc11afb68a37e458ba1c8397a4 | Vincent Prouillet | 2021-05-26T22:02:13 | revamp tests | diff --git a/src/ast.rs b/src/ast.rs
index 8ad5cb8..bbb2e10 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -4,26 +4,6 @@ use std::string::String as StdString;
use crate::lexer::Operator;
-// TODO: have a Span trait/struct for location for error reporting?
-//
-// /// Whether to remove the whitespace of a `{% %}` tag
... | 8 | 549 | 488 |
e3a9abd8f7782a9d18f4f1653c119e262c3902a2 | Vincent Prouillet | 2021-05-26T19:18:44 | next_or_error | diff --git a/src/ast.rs b/src/ast.rs
index 1276cc0..8ad5cb8 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1,7 +1,8 @@
+use std::collections::HashMap;
use std::fmt;
+use std::string::String as StdString;
use crate::lexer::Operator;
-use std::collections::HashMap;
// TODO: have a Span trait/struct for location for ... | 2 | 65 | 35 |
117eeddde0ce42aaf620513da9a62fb35093629b | Lars Eggert | 2026-01-23T01:19:36 | Replace `unicode-xid` crate with `unicode-ident` (#538) | diff --git a/impl/Cargo.toml b/impl/Cargo.toml
index fcabe14..46f4840 100644
--- a/impl/Cargo.toml
+++ b/impl/Cargo.toml
@@ -27,7 +27,7 @@ proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0.45"
convert_case = { version = "0.10", optional = true }
-unicode-xid = { version = "0.2.2", optional = true }
+unicode-ident = { ver... | 2 | 7 | 7 |
562728278427745ced3e22715b70abdc0dfbac07 | Kai Ren | 2025-12-19T17:57:44 | Remove glob imports in `derive(From)` tests to mend 1.94 nightly Rust regression (#528, #525) | diff --git a/tests/from.rs b/tests/from.rs
index 0fcb0b3..930a172 100644
--- a/tests/from.rs
+++ b/tests/from.rs
@@ -13,14 +13,13 @@ use alloc::{
#[cfg(feature = "std")]
use std::borrow::Cow;
-use derive_more::From;
use static_assertions::assert_not_impl_any;
mod structs {
use super::*;
mod unit {
-... | 1 | 66 | 55 |
cc5a45170eadd9891f9904dc28c10fe1397f3a7e | goldlinker | 2025-10-27T14:52:16 | Fix typo in inner docs of `#[display(rename_all = ...)]` attribute (#509)
Signed-off-by: goldlinker <goldlinker@outlook.jp> | diff --git a/impl/src/fmt/display.rs b/impl/src/fmt/display.rs
index dfd75ae..2bd4bbc 100644
--- a/impl/src/fmt/display.rs
+++ b/impl/src/fmt/display.rs
@@ -94,7 +94,7 @@ pub fn expand(input: &syn::DeriveInput, trait_name: &str) -> syn::Result<TokenSt
/// while multiple `#[<attribute>(bound(...))]` are allowed.
#[der... | 1 | 1 | 1 |
c0602e6c16141fcc73992fcebf733d500bc756f9 | Kai Ren | 2025-06-27T12:42:26 | Make Clippy happy for 1.88 Rust (#487) | diff --git a/impl/src/fmt/mod.rs b/impl/src/fmt/mod.rs
index c803a56..d110995 100644
--- a/impl/src/fmt/mod.rs
+++ b/impl/src/fmt/mod.rs
@@ -728,7 +728,7 @@ mod fmt_attribute_spec {
fn assert<'a>(input: &'a str, parsed: impl AsRef<[&'a str]>) {
let parsed = parsed.as_ref();
- let attr = syn::pars... | 3 | 41 | 41 |
9846c51a97a4adc1c831038b16708b9514ba73d5 | Kien Dang | 2025-06-25T16:55:46 | Make `rustc` linter happy with upcoming lints (#486)
- Satisfy a new `mismatched-lifetime-syntaxes` lint introduced in
rust-lang/rust#138677.
- Fix `dead_code` warnings probably since rust-lang/rust#142485.
Co-authored-by: Kai Ren <tyranron@gmail.com> | diff --git a/impl/src/fmt/parsing.rs b/impl/src/fmt/parsing.rs
index ff4fbd0..49ee07f 100644
--- a/impl/src/fmt/parsing.rs
+++ b/impl/src/fmt/parsing.rs
@@ -280,7 +280,7 @@ pub(crate) fn format(input: &str) -> Option<(LeftToParse<'_>, Format<'_>)> {
/// ```
///
/// [0]: std::fmt#syntax
-fn argument(input: &str) -> O... | 2 | 2 | 1 |
92da5d86d4998675926c79b28e4d47735d8f30f3 | Kai Ren | 2025-06-02T18:06:50 | Fix `FromStr` generics check (#476)
Follows #468
## Synopsis
In #468, the `FromStr` derive was reworked. However, the check for
inferring trait bounds for the inner type was simplified to
`!generics.params.is_empty()`, which is not a very correct assumption,
because applies the redundant bounds for cases like these:... | diff --git a/impl/Cargo.toml b/impl/Cargo.toml
index 1d1ca52..0dcacdd 100644
--- a/impl/Cargo.toml
+++ b/impl/Cargo.toml
@@ -57,10 +57,10 @@ debug = ["syn/extra-traits", "dep:unicode-xid"]
deref = []
deref_mut = []
display = ["syn/extra-traits", "dep:unicode-xid", "dep:convert_case"]
-eq = ["syn/extra-traits", "syn/... | 4 | 135 | 16 |
4de3ae782a774b274967d866d8271acfb1ab9a39 | Kai Ren | 2025-04-18T11:52:42 | Run endianess-dependent tests under `#[cfg(target_endian = "little")]` (#452, #451) | diff --git a/tests/debug.rs b/tests/debug.rs
index 0f7fcf1..ede57c8 100644
--- a/tests/debug.rs
+++ b/tests/debug.rs
@@ -784,6 +784,7 @@ mod structs {
}
}
+ #[cfg(target_endian = "little")]
mod r#unsized {
#[cfg(not(feature = "std"))]
use alloc::format;
... | 2 | 2 | 0 |
fdf6f1d8c99bd48f5fc243df71e1e83d595b6f45 | Jun Jiang | 2025-03-26T14:18:35 | Fix `#[doc]` attrubte requiring `std` (#453)
## Synopsis
When compiling on `wasm32-none` target, it fails with the error
```
error[E0463]: can't find crate for `std`
|
= note: the `wasm32v1-none` target may not support the standard library
= note: `std` is required by `derive_more` because it does not d... | diff --git a/src/lib.rs b/src/lib.rs
index e878f5d..814bf84 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,7 +39,7 @@
feature = "from",
feature = "into"
),
- doc = include_str!("../README.md")
+ doc = core::include_str!("../README.md")
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cf... | 1 | 1 | 1 |
a78d8ee41dc4c5fd73572b65dee4cc1369a4c6f1 | Jelte Fennema-Nio | 2025-02-03T20:17:45 | chore: Release | diff --git a/Cargo.toml b/Cargo.toml
index c9b445f..5391d7e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "derive_more"
-version = "2.0.0"
+version = "2.0.1"
edition = "2021"
rust-version = "1.75.0"
description = "Adds #[derive(x)] macros for more traits"
@@ -27,7 +27,7 @@ include = [
... | 2 | 3 | 3 |
5afbaa1d8e776ba86b8341b19519720ddee0e50c | Jelte Fennema-Nio | 2025-02-03T20:01:15 | Add Rust Playground metadata (#445)
derive_more is being pulled into the playground due to being a
dependency of some other crate in the top 100 crates, probably
<https://docs.rs/selectors>.
This adds metadata so that it gets installed with all features once
selectors updates to derive_more 2.0 | diff --git a/Cargo.toml b/Cargo.toml
index 7349f6b..c9b445f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -44,6 +44,9 @@ github = { repository = "JelteF/derive_more", workflow = "CI" }
features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]
+[package.metadata.playground]
+features = ["full", "std"]
+
[lints.rust]
un... | 1 | 3 | 0 |
d7f5b9e94d024790682f6fc4dcca13941cce64c8 | Jelte Fennema-Nio | 2024-08-07T17:29:06 | chore: Release | diff --git a/Cargo.toml b/Cargo.toml
index e6ebbc6..7eedea8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "derive_more"
-version = "1.0.0-beta.7"
+version = "1.0.0"
edition = "2021"
rust-version = "1.75.0"
description = "Adds #[derive(x)] macros for more traits"
@@ -27,7 +27,7 @@ includ... | 2 | 3 | 3 |
b713835894454cd0246dd80e13ce72cb056c82b0 | Jelte Fennema-Nio | 2024-08-06T20:35:03 | Improve error when not enabling any features | diff --git a/impl/src/lib.rs b/impl/src/lib.rs
index a4ecebc..eeccdb0 100644
--- a/impl/src/lib.rs
+++ b/impl/src/lib.rs
@@ -72,6 +72,10 @@ mod unwrap;
// the derives. A derive can generally be infallible and
// return a TokenStream, or it can be fallible and return
// a Result<TokenStream, syn::parse::Error>.
+//
+... | 2 | 8 | 1 |
330e4252fbc12e41794f7f5e164e96423f6f9ff1 | Jelte Fennema-Nio | 2024-08-06T19:42:14 | Order features in Cargo.toml alphabetically | diff --git a/Cargo.toml b/Cargo.toml
index 698b1ff..e6ebbc6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -50,8 +50,8 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(ci)", "cfg(nightly)"] }
[features]
default = ["std"]
-add_assign = ["derive_more-impl/add_assign"]
add = ["derive_more-impl/add"]
+add_assign ... | 1 | 20 | 20 |
57867609d01b7d5ab05c9a1661996436f06cc657 | Jelte Fennema-Nio | 2024-08-01T18:09:35 | chore: Release | diff --git a/Cargo.toml b/Cargo.toml
index 5def63b..698b1ff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "derive_more"
-version = "1.0.0-beta.6"
+version = "1.0.0-beta.7"
edition = "2021"
rust-version = "1.75.0"
description = "Adds #[derive(x)] macros for more traits"
@@ -27,7 +27,7 @@... | 2 | 3 | 3 |
efbd8ed26b8d71b5a22f5f97137db6f672e2b936 | Jelte Fennema-Nio | 2024-07-25T13:47:58 | Only put `Display`-like bounds on type variables (#387, #363)
Resolves #363
Requires #377
Follows #371
## Synopsis
The problem is that the `Display` derive adds bounds for all types
that
are used in the format string. But this is not necessary for types that
don't contain a type variable. And adding those b... | diff --git a/impl/src/fmt/debug.rs b/impl/src/fmt/debug.rs
index 524f021..212860d 100644
--- a/impl/src/fmt/debug.rs
+++ b/impl/src/fmt/debug.rs
@@ -11,7 +11,10 @@ use crate::utils::{
Either, Spanning,
};
-use super::{trait_name_to_attribute_name, ContainerAttributes, FmtAttribute};
+use super::{
+ trait_nam... | 4 | 345 | 118 |
162535e806dbc98422f1399319752dab6fe8617c | Gustav Sörnäs | 2024-07-19T10:09:42 | Only put Debug-like bounds on type variables (#371, #363)
## Synopsis
The problem, as reported in the issue, is that code like the following
```rust
#[derive(derive_more::Debug)]
struct Item {
next: Option<Box<Item>>,
}
```
expands into something like
```rust
impl std::fmt::Debug for Item where I... | diff --git a/impl/src/fmt/debug.rs b/impl/src/fmt/debug.rs
index 9b4e99f..524f021 100644
--- a/impl/src/fmt/debug.rs
+++ b/impl/src/fmt/debug.rs
@@ -24,9 +24,21 @@ pub fn expand(input: &syn::DeriveInput, _: &str) -> syn::Result<TokenStream> {
.unwrap_or_default();
let ident = &input.ident;
+ let type... | 3 | 276 | 6 |
647e3a5cc29446358744cc01b9e615c620c3c5b0 | Jelte Fennema-Nio | 2024-07-08T10:21:24 | Fix `TryInto` derive for generics (#384)
## Synopsis
Our `TryFrom` derive would fail when the type had any generics, this was
a bug introduced with our changes for 1.0.
## Solution
This fixes that by correctly adding the generic parameters to the
`Error` type of `TryFrom`. | diff --git a/impl/src/try_into.rs b/impl/src/try_into.rs
index 4647827..a2ebce8 100644
--- a/impl/src/try_into.rs
+++ b/impl/src/try_into.rs
@@ -104,7 +104,7 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
impl #impl_generics derive_more::core::convert::TryFrom<
... | 3 | 17 | 2 |
3ec4c92134ba752df7de1ef27fa71455b391b2a1 | Jelte Fennema-Nio | 2024-07-05T21:16:35 | Re-enable commented out test (#379)
While doing other things I noticed that this test was commented out for
seemingly no reason. | diff --git a/tests/lib.rs b/tests/lib.rs
index 783edd5..59632fc 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -248,7 +248,10 @@ fn main() {
assert_eq!(MyInt(50), MyInt(5) * 10);
assert_eq!(DoubleUInt(5, 6) * 10, DoubleUInt(50, 60));
- // assert_eq!(DoubleUIntStruct{x:5, y:6} * 10, DoubleUIntStruct{x:50... | 1 | 4 | 1 |
974824ab92bf95f8b463c13e4d4e1716a767e053 | Jelte Fennema-Nio | 2024-07-04T09:55:36 | Don't use double ref vars in Debug derive (#380, #289, #382)
## Synopsis
While looking into #328 I realized the current situation around Pointer
derives
and references was even weirder because we store a double-reference to
the
fields in the local variables for Debug, but not for Display. The reason
we
were d... | diff --git a/impl/src/fmt/debug.rs b/impl/src/fmt/debug.rs
index 68e873e..9b4e99f 100644
--- a/impl/src/fmt/debug.rs
+++ b/impl/src/fmt/debug.rs
@@ -82,7 +82,7 @@ fn expand_struct(
.ident
.clone()
.map_or_else(|| syn::Member::Unnamed(i.into()), syn::Member::Named);
- quote!... | 1 | 3 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.