diff --git a/techtree-manager/src/collect.rs b/techtree-manager/src/collect.rs index 7d1dcb8..ef3eca1 100644 --- a/techtree-manager/src/collect.rs +++ b/techtree-manager/src/collect.rs @@ -111,22 +111,18 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result = labels .iter() .filter_map(|l| l.name.as_deref()) - .filter(|l| l.starts_with("Type/")) + .filter_map(|l| l.strip_prefix("Type/")) .collect(); - if ty_labels.len() == 0 { - anyhow::bail!("Issue #{issue_number} has no type label!"); - } - if ty_labels.len() > 1 { - anyhow::bail!("Issue #{issue_number} has more than one type label!"); - } - - let ty = ty_labels - .first() - .expect("TODO") - .strip_prefix("Type/") - .expect("TODO") - .to_owned(); + let ty = match &ty_labels[..] { + [ty] => ty.to_string(), + [] => { + anyhow::bail!("Issue #{issue_number} has no type label!"); + } + [..] => { + anyhow::bail!("Issue #{issue_number} has more than one type label!"); + } + }; let has_completed_label = labels .iter()