Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::iter::Iterator;
- // Type your code here, or load an example.
- pub fn square_list(nums: impl Iterator<Item = i32>) -> impl Iterator<Item = i32> {
- nums.map(|x| x * x)
- }
- fn main() {
- println!(
- "{:?}",
- square_list(vec![1, 2, 3].into_iter()).collect::<Vec<i32>>()
- );
- }
Add Comment
Please, Sign In to add comment