Skip to content

Commit

Permalink
refactor(rand): use writeln to write to stdout
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed May 13, 2024
1 parent 457e7c1 commit 606318f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions examples/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ fn main() {
let mut stdout = wasi::cli::stdout::get_stdout();

let r: u64 = HostRng.gen();
stdout
.write_all(format!("Cryptographically-secure random u64 is {r}\n").as_bytes())
.unwrap();
writeln!(stdout, "Cryptographically-secure random u64 is {r}").unwrap();

let r: u64 = HostInsecureRng.gen();
stdout
.write_all(format!("Pseudo-random u64 is {r}\n").as_bytes())
.unwrap();
writeln!(stdout, "Pseudo-random u64 is {r}").unwrap();

stdout.flush().unwrap();
}

0 comments on commit 606318f

Please sign in to comment.