#[non_exhaustive]pub enum SourceMapError {
SpaceExhausted {
needed: u64,
available: u64,
},
}Expand description
The reason a source could not be added to a SourceMap.
Every source in a map shares one 32-bit global position space, so the
combined byte length of all sources cannot exceed u32::MAX, and the map can
hold at most u32::MAX distinct sources. Adding a source that would cross
either limit fails with this error rather than wrapping a base offset into a
neighbour’s range — the one way the coordinate bookkeeping could otherwise
corrupt silently.
The enum is #[non_exhaustive]: later phases add file-loading failures
(missing path, oversize file) alongside this variant, and a match on it
must already account for that.
§Examples
use source_lang::{SourceMap, SourceMapError};
// A map whose global space is almost full rejects a source that overruns it.
let mut map = SourceMap::new();
let id = map.add("ok.txt", "fits fine").expect("plenty of room");
assert_eq!(map.source(id).map(|f| f.name()), Some("ok.txt"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SpaceExhausted
The source did not fit in what remained of the map’s capacity.
Returned when the new source is larger than the bytes left in the global
position space — either because the single source exceeds u32::MAX
bytes, or because earlier sources have consumed the remainder — or when
the map already holds the maximum number of sources. The caller cannot
retry the same source against the same map; it must split the input or
start a fresh map.
Trait Implementations§
Source§impl Clone for SourceMapError
impl Clone for SourceMapError
Source§fn clone(&self) -> SourceMapError
fn clone(&self) -> SourceMapError
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 SourceMapError
Source§impl Debug for SourceMapError
impl Debug for SourceMapError
Source§impl Display for SourceMapError
impl Display for SourceMapError
impl Eq for SourceMapError
Source§impl Error for SourceMapError
impl Error for SourceMapError
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 PartialEq for SourceMapError
impl PartialEq for SourceMapError
Source§fn eq(&self, other: &SourceMapError) -> bool
fn eq(&self, other: &SourceMapError) -> bool
self and other values to be equal, and is used by ==.