Logo

Programming-Idioms

History of Idiom 165 > diff from v41 to v42

Edit summary for version 42 by programming-idioms.org:
[Rust] Slightly more unambiguous demo

Version 41

2019-09-09, 09:18:32

Version 42

2019-09-09, 09:20:13

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
let x = items.last().unwrap();
Code
let x = items.last().unwrap();
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bcbcca365b871f285c751a89f065ddef
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f428a604d36831a3d3f436ee16fbac84