From 828a2b5ab4bd8ed0d2475dedf23fd9bde52b1cfc Mon Sep 17 00:00:00 2001 From: Arian Rezazadeh Date: Sat, 4 Jan 2025 10:48:02 +0330 Subject: [PATCH] feat: unwrap instead of returning error when it's safe --- crates/cli/src/commands/format.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/cli/src/commands/format.rs b/crates/cli/src/commands/format.rs index e6861357b..87187360e 100644 --- a/crates/cli/src/commands/format.rs +++ b/crates/cli/src/commands/format.rs @@ -56,12 +56,10 @@ async fn format_file_resovled_patterns( patterns: Vec, 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 {