#[non_exhaustive]pub enum InternError {
SymbolSpaceExhausted,
}Expand description
An error returned when a string cannot be interned.
Interning a new string consumes one symbol from a finite space. When that
space is exhausted there is no symbol left to assign, and
try_intern reports it with this error rather
than panicking or aliasing the string onto an existing symbol.
This enum is #[non_exhaustive]: future releases may add variants for new
failure modes without it being a breaking change, so a match on it must
include a wildcard arm.
§Examples
use intern_lang::{InternError, Interner};
let mut interner = Interner::new();
// Far below the symbol-space bound, interning always succeeds.
assert!(interner.try_intern("name").is_ok());
fn describe(err: InternError) -> &'static str {
match err {
InternError::SymbolSpaceExhausted => "out of symbols",
_ => "unknown interning error",
}
}
assert_eq!(describe(InternError::SymbolSpaceExhausted), "out of symbols");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SymbolSpaceExhausted
The symbol space is exhausted: the interner has already issued all
u32::MAX symbols, so no new string can be assigned one.
Reaching this requires interning over four billion distinct strings,
which exhausts memory on any normal machine long before the symbol space.
A caller that must handle the boundary explicitly — rather than relying on
it being unreachable — should use
try_intern and treat this variant as a
hard stop: the interner cannot accept further distinct strings.
Trait Implementations§
Source§impl Clone for InternError
impl Clone for InternError
Source§fn clone(&self) -> InternError
fn clone(&self) -> InternError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InternError
Source§impl Debug for InternError
impl Debug for InternError
Source§impl Display for InternError
impl Display for InternError
impl Eq for InternError
Source§impl Error for InternError
impl Error for InternError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl Hash for InternError
impl Hash for InternError
Source§impl PartialEq for InternError
impl PartialEq for InternError
Source§fn eq(&self, other: &InternError) -> bool
fn eq(&self, other: &InternError) -> bool
self and other values to be equal, and is used by ==.