-
-
Save dancingfrog/09a4f12d1c599376037d00f054ac359f 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
// https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=09a4f12d1c599376037d00f054ac359f | |
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