Skip to content

Commit

Permalink
feat: unwrap instead of returning error when it's safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian8j2 committed Jan 4, 2025
1 parent 570ff55 commit 828a2b5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/cli/src/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ async fn format_file_resovled_patterns(
patterns: Vec<ResolvedGritDefinition>,
arg: FormatArgs,
) -> Result<()> {
// patterns has atleast one resolve so unwrap is safe
let first_pattern = patterns.first().unwrap();
let first_pattern_raw_data = first_pattern
.config
.raw
.as_ref()
.ok_or_else(|| anyhow!("pattern does not have config raw data"))?;
// currently all patterns has raw data so unwrap is safe
let first_pattern_raw_data = first_pattern.config.raw.as_ref().unwrap();
let old_file_content = &first_pattern_raw_data.content;

let new_file_content = match first_pattern_raw_data.format {
Expand Down

0 comments on commit 828a2b5

Please sign in to comment.