/// Checks that the given list of P-states satisfies the following conditions:
///  - Contains at least one element;
///  - Is primarily sorted by frequency;
///  - Is strictly secondarily sorted by voltage.
Checks that the given list of P-states satisfies the following conditions:
Contains at least one element;
Is primarily sorted by frequency;
Is strictly secondarily sorted by voltage.
Checks that the given list of P - states satisfies the following conditions : Contains at least one element ; Is primarily sorted by frequency ; Is strictly secondarily sorted by voltage .
fn validate_pstates(pstates: &Vec<PState>) -> Result<(), Error> {
        if pstates.len() == 0 {
            anyhow::bail!("Must have at least one P-state");
        } else if pstates.len() > 1 {
            for pair in pstates.as_slice().windows(2) {
                if pair[1].frequency > pair[0].frequency
                    || (pair[1].frequency == pair[0].frequency
                        && pair[1].voltage >= pair[0].voltage)
                {
                    anyhow::bail!(
                        "P-states must be primarily sorted by decreasing frequency and secondarily \
                        sorted by decreasing voltage; violated by {:?} and {:?}.",
                        pair[0],
                        pair[1]
                    );
                }
            }
        }
        Ok(())
    }
fn validate_pstates ( pstates : & Vec < PState > ) -> Result < ( ) , Error > { if pstates . len ( ) == 0 { anyhow :: bail ! ( " " ) ; } else if pstates . len ( ) > 1 { for pair in pstates . as_slice ( ) . windows ( 2 ) { if pair [ 1 ] . frequency > pair [ 0 ] . frequency || ( pair [ 1 ] . frequency == pair [ 0 ] . frequency && pair [ 1 ] . voltage >= pair [ 0 ] . voltage ) { anyhow :: bail ! ( " \
 " pair [ 0 ] pair [ 1 ] ) ; } } } Ok ( ( ) ) }
Checks that the given list of P-states satisfies the following conditions:
 Contains at least one element;
 Is primarily sorted by frequency;
 Is strictly secondarily sorted by voltage.
Checks that the given list of P - states satisfies the following conditions : Contains at least one element ; Is primarily sorted by frequency ; Is strictly secondarily sorted by voltage .
pstates
&Vec<PState>