pub fn init(line: &str) -> (HashMap<isize, isize>, isize, isize) {
    let mut last = 0;

    let mut map: HashMap<_, _> = String::from(line).split(",")
        .map(|v| v.parse::<isize>().expect("Could not parse number"))
        .enumerate()
        .map(|(pos, value)| {
            last = value;
            (value, pos as isize)
        }).collect();

    let start = map.remove(&last).unwrap() + 1;

    assert_eq!(start as usize, map.len() + 1, "Initialization from non-unique numbers not allowed.");

    (map, last, start)
}
// tag::init[]
/// Initialize map for memory game
///
/// The input is expected to be a comma separated list of integers
/// The function returns a map where the values in the input list are the keys and their position's
/// in the input list are their values. The last value is not in the map but returned in addition to
/// the map. The third return value is the number of the round to start playing on this map.
///
/// # Panics
///
/// This function panics if the input list is not a comma separated list of distinct integer values
:init[]
Initialize map for memory game

The input is expected to be a comma separated list of integers
The function returns a map where the values in the input list are the keys and their position's
in the input list are their values. The last value is not in the map but returned in addition to
the map. The third return value is the number of the round to start playing on this map.
: init [] Initialize map for memory game The input is expected to be a comma separated list of integers The function returns a map where the values in the input list are the keys and their position ' s in the input list are their values . The last value is not in the map but returned in addition to the map . The third return value is the number of the round to start playing on this map .
pub fn init(line: &str) -> (HashMap<isize, isize>, isize, isize) {
    let mut last = 0;
    let mut map: HashMap<_, _> = String::from(line).split(",")
        .map(|v| v.parse::<isize>().expect("Could not parse number"))
        .enumerate()
        .map(|(pos, value)| {
            last = value;
            (value, pos as isize)
        }).collect();
    let start = map.remove(&last).unwrap() + 1;
    assert_eq!(start as usize, map.len() + 1, "Initialization from non-unique numbers not allowed.");
    (map, last, start)
}
pub fn init ( line : & str ) -> ( HashMap < isize , isize > , isize , isize ) { let mut last = 0 ; let mut map : HashMap < _ , _ > = String :: from ( line ) . split ( " " ) . map ( | v | v . parse :: < isize > ( ) . expect ( " " ) ) . enumerate ( ) . map ( | ( pos , value ) | { last = value ; ( value , pos as isize ) } ) . collect ( ) ; let start = map . remove ( & last ) . unwrap ( ) + 1 ; assert_eq ! ( start as usize map len ( ) 1 " " ) ; ( map , last , start ) }
tag::init[]
Initialize map for memory game
tag :: init [] Initialize map for memory game
line
&str
line
&str
panics
This function panics if the input list is not a comma separated list of distinct integer values
This function panics if the input list is not a comma separated list of distinct integer values