ferricml 0.2.1

A lean, pure-Rust toolkit for classical machine learning
Documentation
use super::SelectionError;

pub(super) fn validate_selection(
    indices: &[usize],
    available: usize,
) -> Result<(), SelectionError> {
    if indices.is_empty() {
        return Err(SelectionError::Empty);
    }
    if let Some((position, &index)) = indices
        .iter()
        .enumerate()
        .find(|(_, index)| **index >= available)
    {
        return Err(SelectionError::IndexOutOfBounds {
            position,
            index,
            available,
        });
    }
    Ok(())
}