Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 18, 2021 11:03
Show Gist options
  • Save rust-play/def2170cfe8a4965d6139ab89246f950 to your computer and use it in GitHub Desktop.
Save rust-play/def2170cfe8a4965d6139ab89246f950 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
extern crate rand;
use rand::Rng;
// use std::str;
// use std::string; // .to_string() is already impl on u8
fn main() {
let mut rng = rand::thread_rng();
let robot = rng.gen::<u8>().to_string();
let greeting: &str = &(format!("Hello, {}!", robot));
print(greeting);
}
fn print(input_string: &str) {
println!("{}", input_string);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment