Validate buffer is non-empty, returning error if empty.
(&self, op: &str)
| 148 | |
| 149 | /// Validate buffer is non-empty, returning error if empty. |
| 150 | pub fn require_non_empty(&self, op: &str) -> ParsecResult<()> { |
| 151 | if self.is_empty() { |
| 152 | Err(ParsecError::EmptyCollection(format!( |
| 153 | "cannot {op} empty buffer" |
| 154 | ))) |
| 155 | } else { |
| 156 | Ok(()) |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | #[cfg(test)] |