Skip to content

Instantly share code, notes, and snippets.

@segfo
Created April 29, 2018 09:10
Show Gist options
  • Save segfo/5cc341a86498f3bdf2f2c576a01067c1 to your computer and use it in GitHub Desktop.
Save segfo/5cc341a86498f3bdf2f2c576a01067c1 to your computer and use it in GitHub Desktop.
Rustでランダム文字列をホイホイ出力
extern crate rand;
use rand::Rng;
fn main() {
let mut vec=(0x20..0x7f)
.filter_map(|n|std::char::from_u32(n as u32))
.collect::<Vec<char>>();
rand::thread_rng().shuffle(&mut vec);
vec.iter().for_each(|n|print!("{}",n));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment