// Copyright 2025-2026 Gabriel Bjørnager Jensen.
//
// SPDX: MIT OR Apache-2.0

//! The [`TryReserveError`] error type.

use core::error::Error;
use core::fmt::{self, Display, Formatter};

#[cfg(feature = "std")]
use std::io;

/// An N-vector could not reserve additional space.
#[non_exhaustive]
#[derive(Debug, Eq, PartialEq)]
pub struct TryReserveError;

impl Display for TryReserveError {
	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
		write!(f, "unable to reserve in n-vector")
	}
}

impl Error for TryReserveError {}

#[cfg(feature = "std")]
impl From<TryReserveError> for io::Error {
	#[inline]
	fn from(_value: TryReserveError) -> Self {
		io::ErrorKind::OutOfMemory.into()
	}
}
