1#[must_use]
5pub fn is_space_git(c: u8) -> bool {
6 matches!(c, b' ' | b'\t' | b'\n' | b'\r' | 0x0b | 0x0c)
7}
8
9#[must_use]
11pub fn ws_blank_line(line: &str) -> bool {
12 line.bytes().all(is_space_git)
13}
14
15#[cfg(test)]
16mod tests {
17 use super::*;
18
19 #[test]
20 fn is_space_git_is_ascii_only() {
21 for c in [b' ', b'\t', b'\n', b'\r', 0x0b, 0x0c] {
22 assert!(is_space_git(c));
23 }
24 assert!(!is_space_git(b'a'));
25 assert!(!is_space_git(0xa0));
26 }
27
28 #[test]
29 fn blank_line_detection() {
30 assert!(ws_blank_line(""));
31 assert!(ws_blank_line(" \t\r\n"));
32 assert!(!ws_blank_line(" x\n"));
33 assert!(!ws_blank_line("\u{a0}\n"));
34 }
35}