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

Code before:
    module.set_segments(match parsed {
        Ok(segments) => segments,
        Err(_error) => {
            log::warn!("Error parsing format string in `status.format`");
            return None;
        }
    });
    Some(module)
}

fn format_exit_code<'a>(
    exit_code: &'a str,
    format: &'a str,
    pipestatus: Option<&str>,
    config: &'a StatusConfig,
    context: &'a Context,
) -> Result<Vec<Segment>, StringFormatterError> {
    let exit_code_int: ExitCode = match exit_code.parse() {
        Ok(i) => i,
        Err(_) => {
            log::warn!("Error parsing exit_code string to int");
            return Ok(Vec::new());
        }
    };

    let hex_status = format!("0x{:X}", exit_code_int as u32);

    let common_meaning = status_common_meaning(exit_code_int);

    let raw_signal_number = match config.recognize_signal_code {
        true => status_to_signal(exit_code_int),
        false => None,
    };
    let signal_number = raw_signal_number.map(|sn| sn.to_string());
    let signal_name = raw_signal_number
        .and_then(|sn| status_signal_name(sn).or_else(|| signal_number.as_deref()));

    // If not a signal and not a common meaning, it should at least print the raw exit code number
    let maybe_exit_code_number = match common_meaning.is_none() && signal_name.is_none() {
        true => Some(exit_code),
        false => None,
    };

    StringFormatter::new(format).and_then(|formatter| {
        formatter
            .map_meta(|var, _| match var {
                "symbol" => match exit_code_int {
                    0 => Some(config.success_symbol),
                    126 if config.map_symbol => Some(config.not_executable_symbol),
                    127 if config.map_symbol => Some(config.not_found_symbol),
                    130 if config.recognize_signal_code && config.map_symbol => {

Review comment (suggestion):
I think this will just work and avoid truncation:

```suggestion
    let hex_status = format!("0x{:X}", exit_code_int);
```

Code after:
    module.set_segments(match parsed {
        Ok(segments) => segments,
        Err(_error) => {
            log::warn!("Error parsing format string in `status.format`");
            return None;
        }
    });
    Some(module)
}

fn format_exit_code<'a>(
    exit_code: &'a str,
    format: &'a str,
    pipestatus: Option<&str>,
    config: &'a StatusConfig,
    context: &'a Context,
) -> Result<Vec<Segment>, StringFormatterError> {
    // First, parse as i64 to accept both i32 or u32, then normalize to i32.
    let exit_code_int: ExitCode = match exit_code.parse::<i64>() {
        Ok(i) => i as ExitCode,
        Err(_) => {
            log::warn!("Error parsing exit_code string to int");
            return Ok(Vec::new());
        }
    };

    let hex_status = format!("0x{:X}", exit_code_int);

    let common_meaning = status_common_meaning(exit_code_int);

    let raw_signal_number = match config.recognize_signal_code {
        true => status_to_signal(exit_code_int),
        false => None,
    };
    let signal_number = raw_signal_number.map(|sn| sn.to_string());
    let signal_name = raw_signal_number
        .and_then(|sn| status_signal_name(sn).or_else(|| signal_number.as_deref()));

    // If not a signal and not a common meaning, it should at least print the raw exit code number
    let maybe_exit_code_number = match common_meaning.is_none() && signal_name.is_none() {
        true => Some(exit_code),
        false => None,
    };

    StringFormatter::new(format).and_then(|formatter| {
        formatter
            .map_meta(|var, _| match var {
                "symbol" => match exit_code_int {
                    0 => Some(config.success_symbol),
                    126 if config.map_symbol => Some(config.not_executable_symbol),
                    127 if config.map_symbol => Some(config.not_found_symbol),