fn fmt_term(term: &Term, f: &mut Formatter<'_>, outermost: bool) -> Result {
    const SUPERSCRIPT_PLUS: u32 = 0x207A;
    // const SUPERSCRIPT_MINUS: u32 = 0x207B;

    match *term {
        Term::Elem { ref name, n } => {
            f.write_str(name)?;
            fmt_coef(n, f, Some(true))?;
        }
        Term::List {
            ref list,
            n,
            charge,
        } => {
            if outermost {
                fmt_coef(n, f, None)?;
                for term in list {
                    fmt_term(term, f, false)?;
                }
            } else {
                f.write_char('(')?;
                for term in list {
                    fmt_term(term, f, false)?;
                }
                f.write_char(')')?;
                fmt_coef(n, f, Some(true))?;
            }
            if charge != 0 {
                let neg = charge < 0;
                fmt_coef(charge.wrapping_abs(), f, Some(false))?;
                f.write_char(char::from_u32(SUPERSCRIPT_PLUS + neg as u32).unwrap())?;
            }
        }
        Term::Electron => f.write_char('e')?,
    }
    Ok(())
}
/// Formats a term within a chemical equation recursively.
///
/// This function generally parenthesizes the lists, formats the coefficients
/// as subscripts and the charges as superscripts.
///
/// The parameter `outermost` specifies that the term is an outermost list, dropping the
/// parentheses around it and formatting its coefficient as preceding ASCII numbers instead.
Formats a term within a chemical equation recursively.
This function generally parenthesizes the lists, formats the coefficients
as subscripts and the charges as superscripts.

The parameter `outermost` specifies that the term is an outermost list, dropping the
parentheses around it and formatting its coefficient as preceding ASCII numbers instead.
Formats a term within a chemical equation recursively . This function generally parenthesizes the lists formats the coefficients as subscripts and the charges as superscripts . The parameter ` outermost ` specifies that the term is an outermost list dropping the parentheses around it and formatting its coefficient as preceding ASCII numbers instead .
fn fmt_term(term: &Term, f: &mut Formatter<'_>, outermost: bool) -> Result {
    const SUPERSCRIPT_PLUS: u32 = 0x207A;
    // const SUPERSCRIPT_MINUS: u32 = 0x207B;
    match *term {
        Term::Elem { ref name, n } => {
            f.write_str(name)?;
            fmt_coef(n, f, Some(true))?;
        }
        Term::List {
            ref list,
            n,
            charge,
        } => {
            if outermost {
                fmt_coef(n, f, None)?;
                for term in list {
                    fmt_term(term, f, false)?;
                }
            } else {
                f.write_char('(')?;
                for term in list {
                    fmt_term(term, f, false)?;
                }
                f.write_char(')')?;
                fmt_coef(n, f, Some(true))?;
            }
            if charge != 0 {
                let neg = charge < 0;
                fmt_coef(charge.wrapping_abs(), f, Some(false))?;
                f.write_char(char::from_u32(SUPERSCRIPT_PLUS + neg as u32).unwrap())?;
            }
        }
        Term::Electron => f.write_char('e')?,
    }
    Ok(())
}
fn fmt_term ( term : & Term , f : & mut Formatter < ' _ > , outermost : bool ) -> Result { const SUPERSCRIPT_PLUS : u32 = 0x207A ; // const SUPERSCRIPT_MINUS: u32 = 0x207B; match * term { Term :: Elem { ref name , n } => { f . write_str ( name ) ? ; fmt_coef ( n , f , Some ( true ) ) ? ; } Term :: List { ref list , n , charge , } => { if outermost { fmt_coef ( n , f , None ) ? ; for term in list { fmt_term ( term , f , false ) ? ; } } else { f . write_char ( '(' ) ? ; for term in list { fmt_term ( term , f , false ) ? ; } f . write_char ( ')' ) ? ; fmt_coef ( n , f , Some ( true ) ) ? ; } if charge != 0 { let neg = charge < 0 ; fmt_coef ( charge . wrapping_abs ( ) , f , Some ( false ) ) ? ; f . write_char ( char :: from_u32 ( SUPERSCRIPT_PLUS + neg as u32 ) . unwrap ( ) ) ? ; } } Term :: Electron => f . write_char ( 'e' ) ? , } Ok ( ( ) ) }
Formats a term within a chemical equation recursively.
Formats a term within a chemical equation recursively .
term
&Term
f
&mut Formatter<'_>
outermost
bool
term
&Term
f
&mut Formatter<'_>
outermost
bool