fn to_score_array<T: Default + Copy>(vec: Vec<T>)
    -> Result<[T; cards::SCORES], ParsingError>
{
    // Ensure that `vec` has the correct length.
    if vec.len() == cards::SCORES {
        // This is optimized away; no need for `unsafe`.
        let mut arr: [T; cards::SCORES] = Default::default();
        // Copy each item over.
        for i in 0..cards::SCORES {
            arr[i] = vec[i];
        }

        Ok(arr)
    } else {
        Err(ParsingError::Other("wrong number of items in the list (expected the number of scores)"))
    }
}
/// Convert vector to array with entries corresponding to `cards::Score`s.
///
/// This is used for settings that takes an entry for each score. It check that the vector is the
/// correct length (`cards::SCORES`) and converts it into an array.
Convert vector to array with entries corresponding to `cards::Score`s.
This is used for settings that takes an entry for each score. It check that the vector is the
correct length (`cards::SCORES`) and converts it into an array.
Convert vector to array with entries corresponding to ` cards :: Score ` s . This is used for settings that takes an entry for each score . It check that the vector is the correct length ( ` cards :: SCORES ` ) and converts it into an array .
fn to_score_array<T: Default + Copy>(vec: Vec<T>)
    -> Result<[T; cards::SCORES], ParsingError>
{
    // Ensure that `vec` has the correct length.
    if vec.len() == cards::SCORES {
        // This is optimized away; no need for `unsafe`.
        let mut arr: [T; cards::SCORES] = Default::default();
        // Copy each item over.
        for i in 0..cards::SCORES {
            arr[i] = vec[i];
        }
        Ok(arr)
    } else {
        Err(ParsingError::Other("wrong number of items in the list (expected the number of scores)"))
    }
}
fn to_score_array < T : Default + Copy > ( vec : Vec < T > ) -> Result < [ T ; cards :: SCORES ] , ParsingError > { // Ensure that `vec` has the correct length. if vec . len ( ) == cards :: SCORES { // This is optimized away; no need for `unsafe`. let mut arr : [ T ; cards :: SCORES ] = Default :: default ( ) ; // Copy each item over. for i in 0 .. cards :: SCORES { arr [ i ] = vec [ i ] ; } Ok ( arr ) } else { Err ( ParsingError :: Other ( " " ) ) } }
Convert vector to array with entries corresponding to `cards::Score`s.
Convert vector to array with entries corresponding to ` cards :: Score ` s .
vec
Vec<T>
vec
Vec<T>