pub struct ElementTable { /* private fields */ }Expand description
An ElementResolver that looks element values up by name in a table the
caller fills: what a test, or a program without a registry, passes to
reader.
Fill it with the structural elements of a language
(with_structural) and the elements its
declarations carry (with,
from_elements). Every element value
inserted under a name is kept. A name held by several values resolves to
the error AmbiguousElement rather than to one of them, because a reader
that has only a name cannot tell which value was written.
Implementations§
Source§impl ElementTable
impl ElementTable
Sourcepub fn new() -> ElementTable
pub fn new() -> ElementTable
Creates an empty table.
Sourcepub fn from_elements(
elements: impl IntoIterator<Item = Arc<ElementSpec>>,
) -> ElementTable
pub fn from_elements( elements: impl IntoIterator<Item = Arc<ElementSpec>>, ) -> ElementTable
Creates a table holding the given element values.
Sourcepub fn with(self, element: Arc<ElementSpec>) -> ElementTable
pub fn with(self, element: Arc<ElementSpec>) -> ElementTable
Builder: adds one element value.
Sourcepub fn with_structural(self, structural: &StructuralElements) -> ElementTable
pub fn with_structural(self, structural: &StructuralElements) -> ElementTable
Builder: adds every element of a set of structural elements, such as a
language’s (BuiltLang::structural).
Sourcepub fn insert(&mut self, element: Arc<ElementSpec>) -> usize
pub fn insert(&mut self, element: Arc<ElementSpec>) -> usize
Adds one element value under its name and returns how many values the
name now holds. The same Arc is never added twice.
Sourcepub fn values(&self, name: &str) -> &[Arc<ElementSpec>]
pub fn values(&self, name: &str) -> &[Arc<ElementSpec>]
Returns the element values held under name, in insertion order (empty
when the name is not held).
Sourcepub fn names(&self) -> impl Iterator<Item = &ElementName> + '_
pub fn names(&self) -> impl Iterator<Item = &ElementName> + '_
Returns the names held, in sorted order.
Trait Implementations§
Source§impl Clone for ElementTable
impl Clone for ElementTable
Source§impl Debug for ElementTable
impl Debug for ElementTable
Source§impl Default for ElementTable
impl Default for ElementTable
Source§impl ElementResolver for ElementTable
impl ElementResolver for ElementTable
Source§fn resolve_element(
&self,
name: &str,
) -> Result<Option<Arc<ElementSpec>>, AmbiguousElement>
fn resolve_element( &self, name: &str, ) -> Result<Option<Arc<ElementSpec>>, AmbiguousElement>
Returns the one value held under name, None when there is none, and
AmbiguousElement when there are several. A table does not record which
feature declared a value, so the error lists the host
(HOST_FEATURE) as the owner, once per value.
Auto Trait Implementations§
impl !RefUnwindSafe for ElementTable
impl !UnwindSafe for ElementTable
impl Forget for ElementTable
impl Freeze for ElementTable
impl Move for ElementTable
impl Send for ElementTable
impl Sync for ElementTable
impl Unpin for ElementTable
impl UnsafeUnpin for ElementTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more