fn parse_number(&self, number: &Value) -> Result<Vec<String>> {
        let mut result = Vec::new();
        match number {
            Value::Number(n) => {
                result.push(n.to_string());
            }
            Value::String(s) => {
                let s = s.to_uppercase();
                let re = Regex::new(r"([A-Z]{0,2})(\d+)\s*\.\.\s*([A-Z]{0,2})(\d+)").unwrap();
                if re.is_match(&s) {
                    let caps = re
                        .captures(&s)
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    let row_begin = self
                        .letters
                        .iter()
                        .position(|s| s.eq(&caps[1]))
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    let mut row_end = self
                        .letters
                        .iter()
                        .position(|s| s.eq(&caps[3]))
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    if row_end < row_begin {
                        row_end = row_begin;
                    }
                    let col_begin = caps[2].parse::<usize>()?;
                    let col_end = caps[4].parse::<usize>()?;
                    ensure!(
                        col_begin < col_end,
                        QedaError::InvalidPinNumber(s.to_string())
                    );
                    for row in row_begin..=row_end {
                        for col in col_begin..=col_end {
                            result.push(format!("{}{}", self.letters[row], col));
                        }
                    }
                } else {
                    result.push(s);
                }
            }
            Value::Array(a) => {
                for n in a {
                    let mut sub_numbers = self.parse_number(n)?;
                    result.append(&mut sub_numbers);
                }
            }
            _ => (), // TODO: Return the error about unexpected type
        }
        Ok(result)
    }
// Parse pin number(s) from string
Parse pin number(s) from string
Parse pin number ( s ) from string
fn parse_number(&self, number: &Value) -> Result<Vec<String>> {
        let mut result = Vec::new();
        match number {
            Value::Number(n) => {
                result.push(n.to_string());
            }
            Value::String(s) => {
                let s = s.to_uppercase();
                let re = Regex::new(r"([A-Z]{0,2})(\d+)\s*\.\.\s*([A-Z]{0,2})(\d+)").unwrap();
                if re.is_match(&s) {
                    let caps = re
                        .captures(&s)
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    let row_begin = self
                        .letters
                        .iter()
                        .position(|s| s.eq(&caps[1]))
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    let mut row_end = self
                        .letters
                        .iter()
                        .position(|s| s.eq(&caps[3]))
                        .ok_or_else(|| QedaError::InvalidPinNumber(s.to_string()))?;
                    if row_end < row_begin {
                        row_end = row_begin;
                    }
                    let col_begin = caps[2].parse::<usize>()?;
                    let col_end = caps[4].parse::<usize>()?;
                    ensure!(
                        col_begin < col_end,
                        QedaError::InvalidPinNumber(s.to_string())
                    );
                    for row in row_begin..=row_end {
                        for col in col_begin..=col_end {
                            result.push(format!("{}{}", self.letters[row], col));
                        }
                    }
                } else {
                    result.push(s);
                }
            }
            Value::Array(a) => {
                for n in a {
                    let mut sub_numbers = self.parse_number(n)?;
                    result.append(&mut sub_numbers);
                }
            }
            _ => (), // TODO: Return the error about unexpected type
        }
        Ok(result)
    }
fn parse_number ( & self , number : & Value ) -> Result < Vec < String > > { let mut result = Vec :: new ( ) ; match number { Value :: Number ( n ) => { result . push ( n . to_string ( ) ) ; } Value :: String ( s ) => { let s = s . to_uppercase ( ) ; let re = Regex :: new ( r"([A-Z]{0,2})(\d+)\s*\.\.\s*([A-Z]{0,2})(\d+)" ) . unwrap ( ) ; if re . is_match ( & s ) { let caps = re . captures ( & s ) . ok_or_else ( | | QedaError :: InvalidPinNumber ( s . to_string ( ) ) ) ? ; let row_begin = self . letters . iter ( ) . position ( | s | s . eq ( & caps [ 1 ] ) ) . ok_or_else ( | | QedaError :: InvalidPinNumber ( s . to_string ( ) ) ) ? ; let mut row_end = self . letters . iter ( ) . position ( | s | s . eq ( & caps [ 3 ] ) ) . ok_or_else ( | | QedaError :: InvalidPinNumber ( s . to_string ( ) ) ) ? ; if row_end < row_begin { row_end = row_begin ; } let col_begin = caps [ 2 ] . parse :: < usize > ( ) ? ; let col_end = caps [ 4 ] . parse :: < usize > ( ) ? ; ensure ! ( col_begin col_end QedaError InvalidPinNumber ( s to_string ( ) ) ) ; for row in row_begin ..= row_end { for col in col_begin ..= col_end { result . push ( format ! ( " " self letters [ row ] col ) ) ; } } } else { result . push ( s ) ; } } Value :: Array ( a ) => { for n in a { let mut sub_numbers = self . parse_number ( n ) ? ; result . append ( & mut sub_numbers ) ; } } _ => ( ) , // TODO: Return the error about unexpected type } Ok ( result ) }
Parse pin number(s) from string
Parse pin number ( s ) from string
&self
number
&Value
&self
number
&Value