Repository: starship/starship
File: src/modules/git_branch.rs (Rust)

Code before:
    let truncation_symbol = get_first_grapheme(config.truncation_symbol);

    let len = if config.truncation_length <= 0 {
        log::warn!(
            "\"truncation_length\" should be a positive value, found {}",
            config.truncation_length
        );
        std::usize::MAX
    } else {
        config.truncation_length as usize
    };

    let repo = context.get_repo().ok()?;

    if config.only_attached {
        if let Ok(git_repo) = repo.open() {
            if git_repo.head_detached().ok()? {
                return None;
            }
        }
    }

    let branch_name = repo.branch.as_ref()?;
    let mut graphemes: Vec<&str> = branch_name.graphemes(true).collect();

    for ignore_branch in config.ignore_branches {
        let ignore_graphemes: Vec<&str> =
            UnicodeSegmentation::graphemes(ignore_branch, true).collect();

        if graphemes.eq(&ignore_graphemes) {
            return None;
        }
    }

    let mut remote_branch_graphemes: Vec<&str> = Vec::new();
    let mut remote_name_graphemes: Vec<&str> = Vec::new();
    if let Some(remote) = repo.remote.as_ref() {
        if let Some(branch) = &remote.branch {
            remote_branch_graphemes = branch.graphemes(true).collect()
        };
        if let Some(name) = &remote.name {
            remote_name_graphemes = name.graphemes(true).collect()
        };
    }

    // Truncate fields if need be
    for e in &mut [
        &mut graphemes,
        &mut remote_branch_graphemes,
        &mut remote_name_graphemes,
    ] {

Review comment (bug):
Not a blocker, but maybe it would be better to use an iterator and the `branch_name` here, something like

```rust
let is_ignored_branch = config.ignored_branches.iter()
    .any(|ignore_branch| branch_name.eq(ignore_branch));

if is_ignored_branch {
    return None;
} 
```

(I am on my phone so the above probably has something wrong with it but hopefully you get the idea). 

Code after:
    let truncation_symbol = get_first_grapheme(config.truncation_symbol);

    let len = if config.truncation_length <= 0 {
        log::warn!(
            "\"truncation_length\" should be a positive value, found {}",
            config.truncation_length
        );
        std::usize::MAX
    } else {
        config.truncation_length as usize
    };

    let repo = context.get_repo().ok()?;

    if config.only_attached {
        if let Ok(git_repo) = repo.open() {
            if git_repo.head_detached().ok()? {
                return None;
            }
        }
    }

    let branch_name = repo.branch.as_ref()?;
    let mut graphemes: Vec<&str> = branch_name.graphemes(true).collect();

    if config
        .ignore_branches
        .iter()
        .any(|ignored| branch_name.eq(ignored))
    {
        return None;
    }

    let mut remote_branch_graphemes: Vec<&str> = Vec::new();
    let mut remote_name_graphemes: Vec<&str> = Vec::new();
    if let Some(remote) = repo.remote.as_ref() {
        if let Some(branch) = &remote.branch {
            remote_branch_graphemes = branch.graphemes(true).collect()
        };
        if let Some(name) = &remote.name {
            remote_name_graphemes = name.graphemes(true).collect()
        };
    }

    // Truncate fields if need be
    for e in &mut [
        &mut graphemes,
        &mut remote_branch_graphemes,
        &mut remote_name_graphemes,
    ] {
        let e = &mut **e;