Search
 
SCRIPT & CODE EXAMPLE
 

RUST

overwritting print on same line rust

use std::{
    io::{stdout, Write},
    thread::sleep,
    time::Duration,
};

fn main() {
    let mut stdout = stdout();

    for i in 0..=100 {
        print!("
Processing {}%...", i);
        // or
        // stdout.write(format!("
Processing {}%...", i).as_bytes()).unwrap();

        stdout.flush().unwrap();
        sleep(Duration::from_millis(20));
    }
    println!();
}
Comment

overwritting print on same line rust

use std::{
    io::{stdout, Write},
    thread::sleep,
    time::Duration,
};

fn main() {
    let mut stdout = stdout();

    for i in 0..=100 {
        print!("
Processing {}%...", i);
        // or
        // stdout.write(format!("
Processing {}%...", i).as_bytes()).unwrap();

        stdout.flush().unwrap();
        sleep(Duration::from_millis(20));
    }
    println!();
}
Comment

PREVIOUS NEXT
Code Example
Rust :: armanriazi•rust•dereferencing 
Rust :: Counting bits Kernighan style 
Rust :: rust•armanriazi•type•wraper 
Rust :: armanriazi•rust•unsafe•function•or•method 
Rust :: rust-analyzer tab space 
Rust :: initialize empty vec in rust 
Rust :: how to get public addres from private key solana cli 
Rust :: Rust Options Some None using closures 
Rust :: rust•armanriazi•thread•sync•sharedstate•mutex 
Rust :: armanriazi•rust•concept•coherence 
Lua :: roblox children for loop 
Lua :: roblox jsonencode 
Lua :: luau how to make region3 
Lua :: roblox __index and __newindex 
Lua :: lua wrap number 
Lua :: roblox how to find value in table 
Lua :: roblox pairs 
Lua :: for loop lua 
Lua :: change material roblox lua 
Lua :: Best way to get player from character? 
Lua :: Roblox Luau Wait Alternative 
Lua :: svelte template 
Lua :: 1.2 / 1.6 
Lua :: lua table concanation 
Matlab :: matlab symbolic derivative 
Matlab :: matlab function files 
Matlab :: matlab new line in string 
Basic :: dos assign command output to variable (when output is a single line) 
Elixir :: what is elixir language 
Elixir :: elixir "hd" programming 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =