Skip to content

Instantly share code, notes, and snippets.

@dancingfrog
Forked from rust-play/playground.rs
Last active April 18, 2021 11:08
Show Gist options
  • Save dancingfrog/09a4f12d1c599376037d00f054ac359f to your computer and use it in GitHub Desktop.
Save dancingfrog/09a4f12d1c599376037d00f054ac359f to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
// 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