pub struct LookupSet<'s, 'i, T: Hash + Eq, V = &'s T> { /* private fields */ }Expand description
Result of a lookup by name in a Scope.
Elements represented by a LookupSet can be filtered and transformed using the
filter(), map(), filter_map(),
and filter_map_ok() functions, which work similarly to
their counterpart on iterators. LookupSet<T, V> represents elements coming from a Scope<T>
and transformed (by map() or filter_map()) into
elements of type V.
The difference from a standard iterator is that LookupSet remembers enough information to allow the one() method to emit detailed error diagnostics. See one() for details.
Implementations§
Source§impl<'s, 'i, T: 's + Hash + Eq, V: 's> LookupSet<'s, 'i, T, V>
impl<'s, 'i, T: 's + Hash + Eq, V: 's> LookupSet<'s, 'i, T, V>
Sourcepub fn name(&self) -> &Identifier<'_>
pub fn name(&self) -> &Identifier<'_>
Get the Identifier the LookupSet was looked up for.
Sourcepub fn filter_map_ok<R: 's>(
self,
f: impl 's + Fn(V) -> Result<Option<R>>,
) -> LookupSet<'s, 'i, T, R>
pub fn filter_map_ok<R: 's>( self, f: impl 's + Fn(V) -> Result<Option<R>>, ) -> LookupSet<'s, 'i, T, R>
Sourcepub fn filter_map<R: 's>(
self,
f: impl 's + Fn(V) -> Option<R>,
) -> LookupSet<'s, 'i, T, R>
pub fn filter_map<R: 's>( self, f: impl 's + Fn(V) -> Option<R>, ) -> LookupSet<'s, 'i, T, R>
Get a LookupSet of the elements of self transformed by the function f for only
the elements v where f(v) returns Some(_).
Sourcepub fn filter(self, f: impl 's + Fn(&V) -> bool) -> Self
pub fn filter(self, f: impl 's + Fn(&V) -> bool) -> Self
Get a LookupSet of only the elements of self that satisfy the predicate f.
Source§impl<'s, 'i, T: 's + Clone + Hash + Eq + Located, V: 's> LookupSet<'s, 'i, T, V>
impl<'s, 'i, T: 's + Clone + Hash + Eq + Located, V: 's> LookupSet<'s, 'i, T, V>
Sourcepub fn one(self) -> Result<V>
pub fn one(self) -> Result<V>
Return the single element in this LookupSet if only one exist, otherwise produce detailed error diagnostics.
The one() method assumes its usage is within name lookup for a typical statically scoped language (this includes quantifiers or other similar constructs in most logics). By calling this method one asserts that only a single result of the previous call to lookup() is required. If this is the case, the single result is returned. Otherwise, error diagnostics are produced.
The diagnostics are produced after checking further conditions. If there were more than one element the lookup is treated as ambiguous (as if you asked for the name of an overloaded function in some C++-like language without specifying its argument types) and a list of matching symbols is produced as attached notes. If the LookupSet is empty the lookup is treated as a reference to an undefined symbol, but if it was filtered (see filter()), then a list of non-matching symbols is produced as attached notes.
Auto Trait Implementations§
impl<'s, 'i, T, V = &'s T> !RefUnwindSafe for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V = &'s T> !Send for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V = &'s T> !Sync for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V = &'s T> !UnwindSafe for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V> Freeze for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V> Unpin for LookupSet<'s, 'i, T, V>
impl<'s, 'i, T, V> UnsafeUnpin for LookupSet<'s, 'i, T, V>where
&'s Scope<T>: UnsafeUnpin,
Box<dyn Iterator<Item = &'s T> + 's>: UnsafeUnpin,
Box<dyn Fn(&'s T) -> Result<Option<V>, DiagnosticEmitted> + 's>: UnsafeUnpin,
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
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