// Reorders the fields returned from the API by the configured `issues_fields` first, and then alphabetically thereafter.
Reorders the fields returned from the API by the configured `issues_fields` first, and then alphabetically thereafter.
Reorders the fields returned from the API by the configured ` issues_fields ` first and then alphabetically thereafter .
fn sort_fields(mut fields: Vec<IssueField>) -> Vec<IssueField> {
  // sort fields by alphabetical order
  fields.sort_unstable_by(|a, b| {
    if a.1 == b.1 {
      return Ordering::Equal;
    }
    match a.1 < b.1 {
      true => Ordering::Less,
      false => Ordering::Greater,
    }
  });
  let mut default_field_names: Vec<(IssueField)> = DEFAULT_ISSUE_FIELDS
    .iter()
    .map(|(id, name)| (id.to_string(), name.to_string()))
    .collect();
  // remove the matching fields that already exists in configuration
  let filtered_fields: Vec<IssueField> = fields
    .into_iter()
    .filter_map(|(id, name)| {
      match default_field_names
        .iter()
        .position(|(_, default_name)| default_name == &name)
      {
        // found a  => remove
        Some(_) => None,
        None => Some((id, name)),
      }
    })
    .collect();
  // then append filtered api fields to configured issues
  default_field_names.extend(filtered_fields);
  default_field_names
}
fn sort_fields ( mut fields : Vec < IssueField > ) -> Vec < IssueField > { // sort fields by alphabetical order fields . sort_unstable_by ( | a , b | { if a . 1 == b . 1 { return Ordering :: Equal ; } match a . 1 < b . 1 { true => Ordering :: Less , false => Ordering :: Greater , } } ) ; let mut default_field_names : Vec < ( IssueField ) > = DEFAULT_ISSUE_FIELDS . iter ( ) . map ( | ( id , name ) | ( id . to_string ( ) , name . to_string ( ) ) ) . collect ( ) ; // remove the matching fields that already exists in configuration let filtered_fields : Vec < IssueField > = fields . into_iter ( ) . filter_map ( | ( id , name ) | { match default_field_names . iter ( ) . position ( | ( _ , default_name ) | default_name == & name ) { // found a  => remove Some ( _ ) => None , None => Some ( ( id , name ) ) , } } ) . collect ( ) ; // then append filtered api fields to configured issues default_field_names . extend ( filtered_fields ) ; default_field_names }
Reorders the fields returned from the API by the configured `issues_fields` first, and then alphabetically thereafter.
Reorders the fields returned from the API by the configured ` issues_fields ` first and then alphabetically thereafter .
fields
Vec<IssueField>