Map vector
Rust
#![allow(unused)]
fn main() {
let v = vec![1, 2, 3];
let new_vec = v.iter().map(|num| {
num * 2
});
}
Python
v = [1, 2, 3];
new_vec = map(num * 2, v)
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
#![allow(unused)]
fn main() {
let v = vec![1, 2, 3];
let new_vec = v.iter().map(|num| {
num * 2
});
}
v = [1, 2, 3];
new_vec = map(num * 2, v)