Skip to content

Commit

Permalink
Merge pull request #1219 from ModProg/trailing_punct
Browse files Browse the repository at this point in the history
Allow trailing punctuation in macros
  • Loading branch information
sebcrozet committed Apr 7, 2023
2 parents 248654b + 181291c commit f5af5db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nalgebra-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Parse for Vector {
elements: Vec::new(),
})
} else {
let elements = MatrixRowSyntax::parse_separated_nonempty(input)?
let elements = MatrixRowSyntax::parse_terminated(input)?
.into_iter()
.collect();
Ok(Self { elements })
Expand Down
13 changes: 13 additions & 0 deletions nalgebra-macros/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ fn dmatrix_small_dims_exhaustive() {
DMatrix::from_row_slice(4, 4, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]));
}

#[test]
fn matrix_trailing_semi() {
matrix![1, 2;];
dmatrix![1, 2;];
}

// Skip rustfmt because it just makes the test bloated without making it more readable
#[rustfmt::skip]
#[test]
Expand Down Expand Up @@ -151,6 +157,13 @@ fn dvector_small_dims_exhaustive() {
assert_eq_and_type!(dvector![1, 2, 3, 4, 5, 6], DVector::from_column_slice(&[1, 2, 3, 4, 5, 6]));
}

#[test]
fn vector_trailing_comma() {
vector![1, 2,];
point![1, 2,];
dvector![1, 2,];
}

#[test]
fn matrix_trybuild_tests() {
let t = trybuild::TestCases::new();
Expand Down

0 comments on commit f5af5db

Please sign in to comment.