Logo

Programming-Idioms

History of Idiom 165 > diff from v25 to v26

Edit summary for version 26 by freecoder:
New Rust implementation by user [freecoder]

Version 25

2018-08-23, 01:02:19

Version 26

2018-12-17, 18:40:03

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();
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bcbcca365b871f285c751a89f065ddef