Skip to main content

implicit_predicates_core/scratch/
error.rs

1//! The error of an arena operation that does not fit.
2
3use core::fmt;
4
5/// The error of a [`Scratch`](super::Scratch) operation whose worst-case result does not fit
6/// in the free part of the arena.
7///
8/// # Examples
9///
10/// ```
11/// use implicit_predicates_core::{Scratch, ScratchExhausted};
12///
13/// let mut buf = [0.0; 1];
14/// let mut scratch = Scratch::borrowed(&mut buf);
15/// assert_eq!(scratch.push(&[1e-20, 1.0]), Err(ScratchExhausted));
16/// assert_eq!(ScratchExhausted.to_string(), "scratch arena exhausted");
17/// ```
18#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub struct ScratchExhausted;
20
21impl fmt::Display for ScratchExhausted {
22    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23        f.write_str("scratch arena exhausted")
24    }
25}
26
27impl core::error::Error for ScratchExhausted {}