elementary-row-operation-verifier 0.0.1

A tool to verify the correctness of elementary row operations on matrices
Documentation
use crate::error::MatrixError;
use crate::filetype;
use crate::parser::types::RawBlock;

/// 从 start 开始收集一个块(到下一空行或末尾),然后解析
pub fn parse_block_at(lines: &[&str], start: usize) -> Result<(RawBlock, usize), MatrixError> {
    let mut block_lines = Vec::new();
    let mut i = start;
    while i < lines.len() && lines[i].trim().is_empty() {
        i += 1;
    }
    if i >= lines.len() {
        return Err(MatrixError::InvalidFormat("Unexpected end".into()));
    }
    block_lines.push(lines[i]);
    i += 1;
    while i < lines.len() && !lines[i].trim().is_empty() {
        block_lines.push(lines[i]);
        i += 1;
    }
    let block = filetype::parse_block(&block_lines)?;
    Ok((block, i))
}