Created
April 25, 2018 23:37
-
-
Save rust-play/83e392197e68ed65190eddc34b444835 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
#![allow(unused)] | |
fn main() { | |
let a = [1, 2, 3]; | |
let ref mut iter = a.into_iter(); | |
let sum: i32 = iter.take(2) | |
.fold(0, |acc, &i| acc + i ); | |
assert_eq!(sum, 3); | |
assert_eq!(iter.next(), Some(&3)); | |
assert_eq!(iter.next(), None); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment