SHARE
TWEET

Untitled

a guest Sep 21st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused_variables)]
  2. use std::slice::Iter;
  3. use std::vec::Vec;
  4.  
  5. fn main() {
  6.     let v: Vec<u8> = vec![1, 2, 3];
  7.  
  8.     let v_iter: Iter<u8> = v.iter();
  9.     println!("{:#?}", v_iter);
  10.  
  11.     for val in v_iter {
  12.         println!("Got with Iterator: {}", val);
  13.     }
  14.     println!("v count = {:#?}", v.iter().count());
  15.    
  16.     println!();
  17.     for val in &v {
  18.         println!("Got without Iterator: {}", val);
  19.     }
  20.     println!("v length = {:#?}", v.len());
  21.    
  22.     println!();
  23.     let a: [i32; 3] = [0; 3];
  24.     let a_iter = a.iter();
  25.     for val in a_iter {
  26.         println!("Got with Iterator: {}", val);
  27.     }
  28.     println!("a count = {:#?}", a.iter().count());
  29.    
  30.     println!();
  31.     for val in &a {
  32.         println!("Got without Iterator: {}", val);
  33.     }
  34.     println!("a length = {:#?}", v.len());
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top