/// perform a roll on a race, returns the race with all the camels in their correct positions.
perform a roll on a race, returns the race with all the camels in their correct positions.
perform a roll on a race returns the race with all the camels in their correct positions .
pub fn perform<R>(&self, roll: R) -> Self
    where
        R: Into<Roll>,
    {
        let roll: Roll = roll.into();
        if self.positions.contains(&Marker::Camel(roll.camel)) {
            let index = self.positions.iter().position(|marker| *marker == Marker::Camel(roll.camel)).unwrap(/* camel is present because of contains check */);
            let offset = self.positions[index..]
                .iter()
                .take_while(|marker| marker.is_a_camel())
                .count();
            let unit = &self.positions[index..(index + offset)];
            let remaining: Vec<Marker> = self.positions[0..index]
                .iter()
                .chain(self.positions[(index + offset)..].iter())
                .chain(repeat(&Marker::Divider).take(4))
                .copied()
                .collect();
            let original_divider_offset = remaining[index..].iter().enumerate().filter(|(_, marker)| marker.is_a_divider()).map(|(index, _)| index).skip(roll.face as usize + 1).nth(0).unwrap(/* offset is present because of repeated divider */);
            let delta: usize = match remaining[index + original_divider_offset - 1] {
                Marker::Oasis => 2,
                Marker::FataMorgana => 0,
                _ => 1,
            };
            let divider_offset = remaining[index..].iter().enumerate().filter(|(_, marker)| marker.is_a_divider()).map(|(index, _)| index).skip(roll.face as usize + delta).nth(0).unwrap(/* offset is present because of repeated divider */);
            let result: Vec<Marker> = remaining[0..(index + divider_offset)]
                .iter()
                .chain(unit.iter())
                .chain(remaining[(index + divider_offset)..].iter())
                .copied()
                .collect();
            Self::from(result)
        } else {
            let positions: Vec<Marker> = self.positions.to_vec();
            Self::from(positions)
        }
    }
pub fn perform < R > ( & self , roll : R ) -> Self where R : Into < Roll > , { let roll : Roll = roll . into ( ) ; if self . positions . contains ( & Marker :: Camel ( roll . camel ) ) { let index = self . positions . iter ( ) . position ( | marker | * marker == Marker :: Camel ( roll . camel ) ) . unwrap ( /* camel is present because of contains check */ ) ; let offset = self . positions [ index .. ] . iter ( ) . take_while ( | marker | marker . is_a_camel ( ) ) . count ( ) ; let unit = & self . positions [ index .. ( index + offset ) ] ; let remaining : Vec < Marker > = self . positions [ 0 .. index ] . iter ( ) . chain ( self . positions [ ( index + offset ) .. ] . iter ( ) ) . chain ( repeat ( & Marker :: Divider ) . take ( 4 ) ) . copied ( ) . collect ( ) ; let original_divider_offset = remaining [ index .. ] . iter ( ) . enumerate ( ) . filter ( | ( _ , marker ) | marker . is_a_divider ( ) ) . map ( | ( index , _ ) | index ) . skip ( roll . face as usize + 1 ) . nth ( 0 ) . unwrap ( /* offset is present because of repeated divider */ ) ; let delta : usize = match remaining [ index + original_divider_offset - 1 ] { Marker :: Oasis => 2 , Marker :: FataMorgana => 0 , _ => 1 , } ; let divider_offset = remaining [ index .. ] . iter ( ) . enumerate ( ) . filter ( | ( _ , marker ) | marker . is_a_divider ( ) ) . map ( | ( index , _ ) | index ) . skip ( roll . face as usize + delta ) . nth ( 0 ) . unwrap ( /* offset is present because of repeated divider */ ) ; let result : Vec < Marker > = remaining [ 0 .. ( index + divider_offset ) ] . iter ( ) . chain ( unit . iter ( ) ) . chain ( remaining [ ( index + divider_offset ) .. ] . iter ( ) ) . copied ( ) . collect ( ) ; Self :: from ( result ) } else { let positions : Vec < Marker > = self . positions . to_vec ( ) ; Self :: from ( positions ) } }
perform a roll on a race, returns the race with all the camels in their correct positions.
perform a roll on a race returns the race with all the camels in their correct positions .
&self
roll
R