Skip to content

Commit 5788b97

Browse files
committed
chore(auto): auto-formatting with new rules
1 parent 01cbdef commit 5788b97

File tree

4 files changed

+769
-717
lines changed

4 files changed

+769
-717
lines changed

src/error.rs

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,44 @@ pub type Result<T> = core::result::Result<T, Error>;
99
/// Simple error enum that wraps common error types
1010
#[derive(Debug, Error)]
1111
pub enum Error {
12-
/// Regex compilation failed
13-
#[error("Invalid regex: {0}")]
14-
Regex(#[from] regex::Error),
15-
16-
/// File system operation failed
17-
#[error("File system error: {0}")]
18-
Io(#[from] std::io::Error),
19-
20-
/// Directory walking failed
21-
#[error("Directory walking error: {0}")]
22-
WalkDir(#[from] walkdir::Error),
23-
24-
/// User provided ambiguous replacement syntax
25-
#[error("{}", format_ambiguous_replacement(ambiguous_whole))]
26-
AmbiguousReplacementSyntax { ambiguous_whole: String, ambiguous_head: String },
12+
/// Regex compilation failed
13+
#[error("Invalid regex: {0}")]
14+
Regex(#[from] regex::Error),
15+
16+
/// File system operation failed
17+
#[error("File system error: {0}")]
18+
Io(#[from] std::io::Error),
19+
20+
/// Directory walking failed
21+
#[error("Directory walking error: {0}")]
22+
WalkDir(#[from] walkdir::Error),
23+
24+
/// User provided ambiguous replacement syntax
25+
#[error("{}", format_ambiguous_replacement(ambiguous_whole))]
26+
AmbiguousReplacementSyntax {
27+
ambiguous_whole: String,
28+
ambiguous_head: String,
29+
},
2730
}
2831

2932
/// Helper function to create error display for `AmbiguousReplacementSyntax`
3033
fn format_ambiguous_replacement(ambiguous_whole: &str) -> String {
31-
// separate digits from dollar
32-
let without_dollar = ambiguous_whole.trim_start_matches('$');
33-
let digits: String = without_dollar.chars().take_while(|c| c.is_ascii_digit()).collect();
34-
let text: String = without_dollar.chars().skip_while(|c| c.is_ascii_digit()).collect();
35-
36-
format!(
37-
"Ambiguous replacement syntax: '{}' is read as '{}' but you probably meant '{}'. Use '{}' instead (or use {{}} around capture group identifiers).",
38-
ambiguous_whole.yellow(),
39-
format!("${{{without_dollar}}}").red(),
40-
format!("${{{}}}{text}", digits).green(),
41-
format!("${{{}}}{text}", digits).green()
42-
)
34+
// separate digits from dollar
35+
let without_dollar = ambiguous_whole.trim_start_matches('$');
36+
let digits: String = without_dollar
37+
.chars()
38+
.take_while(|c| c.is_ascii_digit())
39+
.collect();
40+
let text: String = without_dollar
41+
.chars()
42+
.skip_while(|c| c.is_ascii_digit())
43+
.collect();
44+
45+
format!(
46+
"Ambiguous replacement syntax: '{}' is read as '{}' but you probably meant '{}'. Use '{}' instead (or use {{}} around capture group identifiers).",
47+
ambiguous_whole.yellow(),
48+
format!("${{{without_dollar}}}").red(),
49+
format!("${{{}}}{text}", digits).green(),
50+
format!("${{{}}}{text}", digits).green()
51+
)
4352
}

0 commit comments

Comments
 (0)