-
-
Save rust-play/def2170cfe8a4965d6139ab89246f950 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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