-
Notifications
You must be signed in to change notification settings - Fork 0
Rust:0..n
springroll edited this page Dec 9, 2019
·
1 revision
Rangeオブジェクト0..n
fn main() {
let n = 4;
for i in 0..n {
print!("{}", i); // 0123
}
let mut range = 0..4;
loop {
match range.next() {
Some(x) => {
print!("{}", x); // 0123
}
None => { break }
}
}
let v = (1..5).map(|x| x*x).collect::<Vec<u32>>();
println!("{:?}", v); // [1, 4, 9, 16]
}