Created
September 13, 2018 10:50
-
-
Save maretekent/67d4606a869f91b092b67d2f459b8ccc to your computer and use it in GitHub Desktop.
snippet to rotate the number
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
use std::collections::VecDeque; | |
fn main() { | |
let num = 1970; | |
let mut buf: VecDeque<_> = num.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect();; | |
for _ in 0..buf.len() { | |
println!("{:?}", buf); | |
let n = buf.pop_front().unwrap(); | |
buf.push_back(n); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment