pub struct ResolutionResult<T> { /* private fields */ }Expand description
Result structure for a namespace resolution.
Implementations§
Source§impl<T> ResolutionResult<T>
impl<T> ResolutionResult<T>
Sourcepub fn new(unresolved_reference: Data<T>) -> Self
pub fn new(unresolved_reference: Data<T>) -> Self
Creates a new, empty resolution result for the given unresolved reference, to be used as a placeholder when no namespace is actually available. It will behave as if resolution failed because the namespace being looked in was itself not resolved. If an item is passed via the reference, it will be returned by as_item(). as_namespace() will return None.
Sourcepub fn filter_items<F: Fn(&T) -> bool>(self, filter: F) -> Self
pub fn filter_items<F: Fn(&T) -> bool>(self, filter: F) -> Self
Filter the resulting items by some predicate. This also filters out namespaces.
Sourcepub fn filter_all_items(self) -> Self
pub fn filter_all_items(self) -> Self
Filter the resulting items by some predicate. This also filters out namespaces.
Sourcepub fn filter_namespaces(self) -> Self
pub fn filter_namespaces(self) -> Self
Filter out anything that isn’t a namespace.
Sourcepub fn expect_one<F1, F2>(
self,
parse_context: &mut Context<'_>,
if_not_applicable: F1,
if_ambiguous: F2,
) -> Self
pub fn expect_one<F1, F2>( self, parse_context: &mut Context<'_>, if_not_applicable: F1, if_ambiguous: F2, ) -> Self
Expects a single item, yielding diagnostics if this isn’t the case. If ambiguous or if all matching elements were not applicable (filtered out), the specified functions are called. They receive the reference name and the parse context as arguments to form a suitable diagnostic message. If they return false, a default diagnostic message will be emitted instead.
Sourcepub fn expect_not_ambiguous<F>(
self,
parse_context: &mut Context<'_>,
if_ambiguous: F,
) -> Self
pub fn expect_not_ambiguous<F>( self, parse_context: &mut Context<'_>, if_ambiguous: F, ) -> Self
Expects zero or one item(s), yielding diagnostics if this isn’t the case. If ambiguous, the specified function is called. It receives the reference name and the parse context as arguments to form a suitable diagnostic message. If it returns false, a default diagnostic message will be emitted instead.
Sourcepub fn expect_multiple<F>(
self,
parse_context: &mut Context<'_>,
if_not_applicable: F,
) -> Self
pub fn expect_multiple<F>( self, parse_context: &mut Context<'_>, if_not_applicable: F, ) -> Self
Expects a one or more items, yielding diagnostics if this isn’t the case. If all matching elements were not applicable (filtered out), the specified functions are called. They receive the reference name and the parse context as arguments to form a suitable diagnostic message. If they return false, a default diagnostic message will be emitted instead.
Sourcepub fn as_item(&self) -> Reference<T>
pub fn as_item(&self) -> Reference<T>
Silently returns the first matching item, if any. If there are none, this just returns an unresolved reference. Use filter_items().expect_one() to formulate error messages if there are multiple or no items available.
Sourcepub fn as_opt_item(&self) -> Option<Reference<T>>
pub fn as_opt_item(&self) -> Option<Reference<T>>
Silently returns the first matching item, if any. Unlike as_item(), this returns None if there are no matches.
Sourcepub fn as_namespace(&self) -> Option<Reference<T>>
pub fn as_namespace(&self) -> Option<Reference<T>>
Silently returns the first matching namespace. Use filter_namespaces().expect_one() to formulate error messages if there are multiple or no namespaces available.
Sourcepub fn expect_not_yet_defined(&self) -> Result<()>
pub fn expect_not_yet_defined(&self) -> Result<()>
Return an error if one or more definitions were found for this name resolution, to be used just before defining a new item.
Trait Implementations§
Source§impl<T: Clone> Clone for ResolutionResult<T>
impl<T: Clone> Clone for ResolutionResult<T>
Source§fn clone(&self) -> ResolutionResult<T>
fn clone(&self) -> ResolutionResult<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for ResolutionResult<T>
impl<T: Debug> Debug for ResolutionResult<T>
Auto Trait Implementations§
impl<T> Freeze for ResolutionResult<T>
impl<T> RefUnwindSafe for ResolutionResult<T>where
T: RefUnwindSafe,
impl<T> Send for ResolutionResult<T>
impl<T> Sync for ResolutionResult<T>
impl<T> Unpin for ResolutionResult<T>
impl<T> UnwindSafe for ResolutionResult<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&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