Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ mod test {
r" Hello  $❤", "\n",
r" ^", "\n",
));
let source = r"Hello  $";
let_assert!(Err(e) = substitute(source, &map));
assert!(e.to_string() == r"Missing variable name");
#[rustfmt::skip]
assert!(e.source_highlighting(source) == concat!(
r" Hello  $", "\n",
r" ^", "\n",
));
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/template/raw/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Variable {
///
/// Returns the parsed variable and the index of the byte after the variable.
fn parse(source: &[u8], finger: usize) -> Result<(Self, usize), ParseError> {
if finger == source.len() {
if finger + 1 >= source.len() {
return Err(error::MissingVariableName {
position: finger,
len: 1,
Expand Down Expand Up @@ -140,8 +140,8 @@ impl Variable {
}

// If there is no matching un-escaped closing brace, it's missing.
let end = finger + find_closing_brace(&source[finger..])
.ok_or(error::MissingClosingBrace { position: finger + 1 })?;
let end = finger
+ find_closing_brace(&source[finger..]).ok_or(error::MissingClosingBrace { position: finger + 1 })?;

let variable = Variable {
name: name_start..name_end,
Expand Down
Loading