calc_lib 2.1.0

A library for calculating things with correct order of operations
Documentation

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct InputReader {
    stream: Vec<char>,
}

impl InputReader {
    pub(crate) fn new<S: Into<String>>(input: S) -> Self {
        Self {
            stream: input.into().chars().collect(),
        }
    }

    pub(crate) fn consume(&mut self) -> Option<char> {
        if self.stream.is_empty() {
            return None;
        }
        Some(self.stream.remove(0))
    }

    pub(crate) fn peek_at(&self, n: usize) -> Option<char> {
        self.stream.get(n).cloned()
    }

    pub(crate) fn peek(&self) -> Option<char> {
        self.peek_at(0)
    }

    pub(crate) fn is_empty(&self) -> bool { self.stream.is_empty() }
}