Skip to content

Commit

Permalink
Allow lifetime annotations in type_expression.
Browse files Browse the repository at this point in the history
Fixes #106.
  • Loading branch information
kaj committed Feb 6, 2022
1 parent 42ac2f8 commit afa7a50
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,13 +11,16 @@ project adheres to

* Breaking change: The generated template functions have a simpler
signature.
* Allow litetimes in template argument types. Issue #106.
* Improve error handling in optional warp support, PR #109.
* Current stable rust is 1.57, MSRV is now 1.46.0.
* Update nom dependency to 7.1.0.
* Update optional rsass to 0.23.0.
* Update env_logger to 0.9 and gotham to 0.7.1 in examples
* Dropped support for warp 0.2 (the warp02 feature and example).

Thanks to @JojiiOfficial for reporting #106.


## Release 0.13.4 - 2021-06-25

Expand Down
9 changes: 9 additions & 0 deletions examples/simple/src/main.rs
Expand Up @@ -320,3 +320,12 @@ fn test_issue_68() {
"Hello!\n\nThe 0 number.\n\nThe 1 number.\n\nThe 2 number.\n\nGood bye!\n",
);
}

/// [Issue #106](https://github.com/kaj/ructe/issues/106)
#[test]
fn lifetimes() {
assert_eq!(
r2s(|o| with_lifetime(o, &["foo", "bar"])),
"\n <p>foo</p>\n\n <p>bar</p>\n\n",
);
}
6 changes: 6 additions & 0 deletions examples/simple/templates/with_lifetime.rs.html
@@ -0,0 +1,6 @@
@* There can be lifetime annotations in argument types. *@
@(arg: &[&'static str])

@for x in arg {
<p>@x</p>
}
1 change: 1 addition & 0 deletions src/template.rs
Expand Up @@ -131,6 +131,7 @@ fn type_expression(input: &[u8]) -> PResult<()> {
map(
tuple((
alt((tag("&"), tag(""))),
opt(delimited(spacelike, tag("'"), rust_name)),
delimited(
spacelike,
alt((tag("impl"), tag("dyn"), tag(""))),
Expand Down

0 comments on commit afa7a50

Please sign in to comment.