1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! The [`InternError`] type returned by fallible interning.
use fmt;
/// 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`](crate::Interner::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");
/// ```