/// Takes the formatted parts and applies the padding.
/// Assumes that the caller already has rendered the parts with required precision,
/// so that `self.precision` can be ignored.
Takes the formatted parts and applies the padding.
Assumes that the caller already has rendered the parts with required precision,
so that `self.precision` can be ignored.
Takes the formatted parts and applies the padding . Assumes that the caller already has rendered the parts with required precision so that ` self . precision ` can be ignored .
fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
        if let Some(mut width) = self.width {
            // for the sign-aware zero padding, we render the sign first and
            // behave as if we had no sign from the beginning.
            let mut formatted = formatted.clone();
            let mut align = self.align;
            let old_fill = self.fill;
            if self.sign_aware_zero_pad() {
                // a sign always goes first
                let sign = unsafe { str::from_utf8_unchecked(formatted.sign) };
                self.buf.write_str(sign)?;
                // remove the sign from the formatted parts
                formatted.sign = b"";
                width = if width < sign.len() { 0 } else { width - sign.len() };
                align = rt::v1::Alignment::Right;
                self.fill = '0';
            }
            // remaining parts go through the ordinary padding process.
            let len = formatted.len();
            let ret = if width <= len { // no padding
                self.write_formatted_parts(&formatted)
            } else {
                self.with_padding(width - len, align, |f| {
                    f.write_formatted_parts(&formatted)
                })
            };
            self.fill = old_fill;
            ret
        } else {
            // this is the common case and we take a shortcut
            self.write_formatted_parts(formatted)
        }
    }
fn pad_formatted_parts ( & mut self , formatted : & flt2dec :: Formatted ) -> Result { if let Some ( mut width ) = self . width { // for the sign-aware zero padding, we render the sign first and // behave as if we had no sign from the beginning. let mut formatted = formatted . clone ( ) ; let mut align = self . align ; let old_fill = self . fill ; if self . sign_aware_zero_pad ( ) { // a sign always goes first let sign = unsafe { str :: from_utf8_unchecked ( formatted . sign ) } ; self . buf . write_str ( sign ) ? ; // remove the sign from the formatted parts formatted . sign = b" " ; width = if width < sign . len ( ) { 0 } else { width - sign . len ( ) } ; align = rt :: v1 :: Alignment :: Right ; self . fill = '0' ; } // remaining parts go through the ordinary padding process. let len = formatted . len ( ) ; let ret = if width <= len { // no padding self . write_formatted_parts ( & formatted ) } else { self . with_padding ( width - len , align , | f | { f . write_formatted_parts ( & formatted ) } ) } ; self . fill = old_fill ; ret } else { // this is the common case and we take a shortcut self . write_formatted_parts ( formatted ) } }
Takes the formatted parts and applies the padding.
Takes the formatted parts and applies the padding .
&mut self
formatted
&flt2dec::Formatted