testmark-rs

style: rustfmt normalization of the testmark crate

commit 9ec06e8229143b9a00384320f17d99955bd24e13 · parent 71242d0778 · browse this tree
Ximianth, 2026-08-10 18:30:13 UTC

Pure formatting, no semantic change: these files predate the repo's
.rustfmt.toml being applied consistently. Separated out so the following
feature commit diffs clean.
diff --git a/crates/testmark/src/document.rs b/crates/testmark/src/document.rs
index 3d32522..669f13d 100644
--- a/crates/testmark/src/document.rs
+++ b/crates/testmark/src/document.rs
@@ -52,7 +52,10 @@ impl Hunk {
 	/// Returns the body string if this is a code hunk, or `None`.
 	pub fn body(&self) -> Option<&str> {
 		match &self.content {
-			HunkContent::Code { body, .. } => Some(body),
+			HunkContent::Code {
+				body,
+				..
+			} => Some(body),
 			HunkContent::Table(_) => None,
 		}
 	}
@@ -60,7 +63,10 @@ impl Hunk {
 	/// Returns the block tag if this is a code hunk, or `None`.
 	pub fn block_tag(&self) -> Option<&str> {
 		match &self.content {
-			HunkContent::Code { block_tag, .. } => Some(block_tag),
+			HunkContent::Code {
+				block_tag,
+				..
+			} => Some(block_tag),
 			HunkContent::Table(_) => None,
 		}
 	}
@@ -229,7 +235,9 @@ impl Document {
 			// Peek at the next line to decide: code fence or pipe table?
 			let next = i + 1;
 			if next >= lines.len() {
-				return Err(ParseError::DanglingComment { line: i + 1 });
+				return Err(ParseError::DanglingComment {
+					line: i + 1,
+				});
 			}
 			if lines[next].starts_with('|') {
 				// Table hunk: consume all consecutive pipe-starting lines.
@@ -240,7 +248,9 @@ impl Document {
 				}
 				// table_end is exclusive; last table line index is table_end - 1.
 				if table_end == table_start {
-					return Err(ParseError::EmptyTable { line: next + 1 });
+					return Err(ParseError::EmptyTable {
+						line: next + 1,
+					});
 				}
 				let raw_lines: Vec<(usize, &str)> = (table_start..table_end)
 					.map(|idx| (idx + 1, lines[idx].as_str()))
@@ -264,13 +274,18 @@ impl Document {
 				}
 				hunks.push(Hunk {
 					name,
-					content: HunkContent::Code { block_tag, body },
+					content: HunkContent::Code {
+						block_tag,
+						body,
+					},
 					line_comment: i,
 					line_end: fence_close,
 				});
 				i = fence_close + 1;
 			} else {
-				return Err(ParseError::DanglingComment { line: i + 1 });
+				return Err(ParseError::DanglingComment {
+					line: i + 1,
+				});
 			}
 		}
 		Ok(Document {
@@ -293,7 +308,11 @@ impl Document {
 	/// - `NewContent::Table` (replaces or sets a table hunk).
 	///
 	/// Returns `None` if no hunk has that name.
-	pub fn patched<'a>(&self, name: &str, new_content: impl Into<NewContent<'a>>) -> Option<String> {
+	pub fn patched<'a>(
+		&self,
+		name: &str,
+		new_content: impl Into<NewContent<'a>>,
+	) -> Option<String> {
 		let h = self.hunk(name)?;
 		let new_content = new_content.into();
 		let mut out: Vec<String> = Vec::new();
@@ -311,7 +330,10 @@ impl Document {
 					out.push(l.clone());
 				}
 			},
-			NewContent::Code { block_tag, body } => {
+			NewContent::Code {
+				block_tag,
+				body,
+			} => {
 				for l in &self.lines[..=h.line_comment] {
 					out.push(l.clone());
 				}
diff --git a/crates/testmark/src/lib.rs b/crates/testmark/src/lib.rs
index 154c9ff..5e0b3af 100644
--- a/crates/testmark/src/lib.rs
+++ b/crates/testmark/src/lib.rs
@@ -24,4 +24,4 @@
 
 mod document;
 
-pub use document::{Document, Hunk, HunkContent, NewContent, ParsedTable, ParseError};
+pub use document::{Document, Hunk, HunkContent, NewContent, ParseError, ParsedTable};
diff --git a/crates/testmark/src/table.rs b/crates/testmark/src/table.rs
index 77c8276..cb55d22 100644
--- a/crates/testmark/src/table.rs
+++ b/crates/testmark/src/table.rs
@@ -4,7 +4,7 @@
 //! (header row, separator row, zero or more data rows) and returns a
 //! [`ParsedTable`].
 
-use crate::document::{ParsedTable, ParseError};
+use crate::document::{ParseError, ParsedTable};
 
 /// Parse raw pipe-table lines into a [`ParsedTable`].
 ///
@@ -14,7 +14,9 @@ use crate::document::{ParsedTable, ParseError};
 pub fn parse_table(lines: &[(usize, &str)]) -> Result<ParsedTable, ParseError> {
 	if lines.is_empty() {
 		// Caller checked for this; provide a sentinel line of 0 (unreachable in practice).
-		return Err(ParseError::EmptyTable { line: 0 });
+		return Err(ParseError::EmptyTable {
+			line: 0,
+		});
 	}
 
 	let header_line_no = lines[0].0;
@@ -23,7 +25,9 @@ pub fn parse_table(lines: &[(usize, &str)]) -> Result<ParsedTable, ParseError> {
 
 	if lines.len() < 2 {
 		// Need at least header + separator.
-		return Err(ParseError::MissingTableSeparator { line: header_line_no });
+		return Err(ParseError::MissingTableSeparator {
+			line: header_line_no,
+		});
 	}
 
 	let sep_line_no = lines[1].0;
@@ -36,7 +40,9 @@ pub fn parse_table(lines: &[(usize, &str)]) -> Result<ParsedTable, ParseError> {
 		});
 	}
 	if !sep_cells.iter().all(|c| is_separator_cell(c)) {
-		return Err(ParseError::MissingTableSeparator { line: sep_line_no });
+		return Err(ParseError::MissingTableSeparator {
+			line: sep_line_no,
+		});
 	}
 
 	let mut rows: Vec<Vec<String>> = Vec::new();
@@ -52,7 +58,10 @@ pub fn parse_table(lines: &[(usize, &str)]) -> Result<ParsedTable, ParseError> {
 		rows.push(cells);
 	}
 
-	Ok(ParsedTable { headers, rows })
+	Ok(ParsedTable {
+		headers,
+		rows,
+	})
 }
 
 /// Emit a [`ParsedTable`] back as markdown lines (without trailing newline on