fn display(&mut self) {
        // Panic if someone pops the default bytes unit...
        let units = &self.units.last().unwrap();
        let total_h = Size(self.total_downloaded, units);
        let sum: usize = self.downloaded_last_few_secs.iter().sum();
        let len = self.downloaded_last_few_secs.len();
        let speed = if len > 0 { sum / len } else { 0 };
        let speed_h = Size(speed, units);
        let elapsed_h = Duration(precise_time_s() - self.start_sec);

        // First, move to the start of the current line and clear it.
        let _ = self.term.carriage_return();
        // We'd prefer to use delete_line() but on Windows it seems to
        // sometimes do unusual things
        // let _ = self.term.as_mut().unwrap().delete_line();
        // So instead we do:
        if let Some(n) = self.displayed_charcount {
            // This is not ideal as very narrow terminals might mess up,
            // but it is more likely to succeed until term's windows console
            // fixes whatever's up with delete_line().
            let _ = write!(self.term, "{}", " ".repeat(n));
            let _ = self.term.flush();
            let _ = self.term.carriage_return();
        }

        let output = match self.content_len {
            Some(content_len) => {
                let content_len_h = Size(content_len, units);
                let content_len = content_len as f64;
                let percent = (self.total_downloaded as f64 / content_len) * 100.;
                let remaining = content_len - self.total_downloaded as f64;
                let eta_h = Duration(remaining / speed as f64);
                format!(
                    "{} / {} ({:3.0} %) {}/s in {} ETA: {}",
                    total_h, content_len_h, percent, speed_h, elapsed_h, eta_h
                )
            }
            None => format!(
                "Total: {} Speed: {}/s Elapsed: {}",
                total_h, speed_h, elapsed_h
            ),
        };

        let _ = write!(self.term, "{}", output);
        // Since stdout is typically line-buffered and we don't print a newline, we manually flush.
        let _ = self.term.flush();
        self.displayed_charcount = Some(output.chars().count());
    }
/// Display the tracked download information to the terminal.
Display the tracked download information to the terminal.
Display the tracked download information to the terminal .
fn display(&mut self) {
        // Panic if someone pops the default bytes unit...
        let units = &self.units.last().unwrap();
        let total_h = Size(self.total_downloaded, units);
        let sum: usize = self.downloaded_last_few_secs.iter().sum();
        let len = self.downloaded_last_few_secs.len();
        let speed = if len > 0 { sum / len } else { 0 };
        let speed_h = Size(speed, units);
        let elapsed_h = Duration(precise_time_s() - self.start_sec);
        // First, move to the start of the current line and clear it.
        let _ = self.term.carriage_return();
        // We'd prefer to use delete_line() but on Windows it seems to
        // sometimes do unusual things
        // let _ = self.term.as_mut().unwrap().delete_line();
        // So instead we do:
        if let Some(n) = self.displayed_charcount {
            // This is not ideal as very narrow terminals might mess up,
            // but it is more likely to succeed until term's windows console
            // fixes whatever's up with delete_line().
            let _ = write!(self.term, "{}", " ".repeat(n));
            let _ = self.term.flush();
            let _ = self.term.carriage_return();
        }
        let output = match self.content_len {
            Some(content_len) => {
                let content_len_h = Size(content_len, units);
                let content_len = content_len as f64;
                let percent = (self.total_downloaded as f64 / content_len) * 100.;
                let remaining = content_len - self.total_downloaded as f64;
                let eta_h = Duration(remaining / speed as f64);
                format!(
                    "{} / {} ({:3.0} %) {}/s in {} ETA: {}",
                    total_h, content_len_h, percent, speed_h, elapsed_h, eta_h
                )
            }
            None => format!(
                "Total: {} Speed: {}/s Elapsed: {}",
                total_h, speed_h, elapsed_h
            ),
        };
        let _ = write!(self.term, "{}", output);
        // Since stdout is typically line-buffered and we don't print a newline, we manually flush.
        let _ = self.term.flush();
        self.displayed_charcount = Some(output.chars().count());
    }
fn display ( & mut self ) { // Panic if someone pops the default bytes unit... let units = & self . units . last ( ) . unwrap ( ) ; let total_h = Size ( self . total_downloaded , units ) ; let sum : usize = self . downloaded_last_few_secs . iter ( ) . sum ( ) ; let len = self . downloaded_last_few_secs . len ( ) ; let speed = if len > 0 { sum / len } else { 0 } ; let speed_h = Size ( speed , units ) ; let elapsed_h = Duration ( precise_time_s ( ) - self . start_sec ) ; // First, move to the start of the current line and clear it. let _ = self . term . carriage_return ( ) ; // We'd prefer to use delete_line() but on Windows it seems to // sometimes do unusual things // let _ = self.term.as_mut().unwrap().delete_line(); // So instead we do: if let Some ( n ) = self . displayed_charcount { // This is not ideal as very narrow terminals might mess up, // but it is more likely to succeed until term's windows console // fixes whatever's up with delete_line(). let _ = write ! ( self term " " " " repeat ( n ) ) ; let _ = self . term . flush ( ) ; let _ = self . term . carriage_return ( ) ; } let output = match self . content_len { Some ( content_len ) => { let content_len_h = Size ( content_len , units ) ; let content_len = content_len as f64 ; let percent = ( self . total_downloaded as f64 / content_len ) * 100. ; let remaining = content_len - self . total_downloaded as f64 ; let eta_h = Duration ( remaining / speed as f64 ) ; format ! ( " " total_h content_len_h percent speed_h elapsed_h eta_h ) } None => format ! ( " " total_h speed_h elapsed_h ) , } ; let _ = write ! ( self term " " output ) ; // Since stdout is typically line-buffered and we don't print a newline, we manually flush. let _ = self . term . flush ( ) ; self . displayed_charcount = Some ( output . chars ( ) . count ( ) ) ; }
Display the tracked download information to the terminal.
Display the tracked download information to the terminal .
&mut self