Created
April 29, 2018 09:10
-
-
Save segfo/5cc341a86498f3bdf2f2c576a01067c1 to your computer and use it in GitHub Desktop.
Rustでランダム文字列をホイホイ出力
This file contains hidden or 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; | |
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