MaybeResPath

Trait MaybeResPath 

Source
pub trait MaybeResPath<'a>: Copy {
    // Required method
    fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>);

    // Provided methods
    fn basic_res(self) -> &'a Res { ... }
    fn res_local_id(self) -> Option<HirId> { ... }
    fn res_local_id_and_ident(self) -> Option<(HirId, &'a Ident)> { ... }
}
Expand description

A HIR node which might be a QPath::Resolved.

The following are resolved paths:

  • A path to a module or crate item.
  • A path to a trait item via the trait’s name.
  • A path to a struct or variant constructor via the original type’s path.
  • A local.

All other paths are TypeRelative and require using PathRes to lookup the resolution.

Required Methods§

Source

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

If this node is a resolved path gets both the contained path and the type associated with it.

Provided Methods§

Source

fn basic_res(self) -> &'a Res

If this node is a resolved path gets it’s resolution. Returns Res::Err otherwise.

Source

fn res_local_id(self) -> Option<HirId>

If this node is a path to a local gets the local’s HirId.

Source

fn res_local_id_and_ident(self) -> Option<(HirId, &'a Ident)>

If this node is a path to a local gets the local’s HirId and identifier.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> MaybeResPath<'a> for &'a Path<'a>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

fn basic_res(self) -> &'a Res

Source§

impl<'a> MaybeResPath<'a> for &QPath<'a>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

impl<'a> MaybeResPath<'a> for &Expr<'a>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

impl<'a> MaybeResPath<'a> for &Pat<'a>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

impl<'a> MaybeResPath<'a> for &PatExpr<'a>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

impl<'a, AmbigArg> MaybeResPath<'a> for &Ty<'a, AmbigArg>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

impl<'a, T: MaybeResPath<'a>> MaybeResPath<'a> for Option<T>

Source§

fn opt_res_path(self) -> (Option<&'a Ty<'a>>, Option<&'a Path<'a>>)

Source§

fn basic_res(self) -> &'a Res

Implementors§