File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,10 @@ pub fn single_segment_path(path: &QPath) -> Option<&PathSegment> {
190190 }
191191}
192192
193- /// Match a `Path` against a slice of segment string literals.
193+ /// Match a `QPath` against a slice of segment string literals.
194+ ///
195+ /// There is also `match_path` if you are dealing with a `rustc::hir::Path` instead of a
196+ /// `rustc::hir::QPath`.
194197///
195198/// # Examples
196199/// ```rust,ignore
@@ -210,6 +213,22 @@ pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool {
210213 }
211214}
212215
216+ /// Match a `Path` against a slice of segment string literals.
217+ ///
218+ /// There is also `match_qpath` if you are dealing with a `rustc::hir::QPath` instead of a
219+ /// `rustc::hir::Path`.
220+ ///
221+ /// # Examples
222+ ///
223+ /// ```rust,ignore
224+ /// if match_path(&trait_ref.path, &paths::HASH) {
225+ /// // This is the `std::hash::Hash` trait.
226+ /// }
227+ ///
228+ /// if match_path(ty_path, &["rustc", "lint", "Lint"]) {
229+ /// // This is a `rustc::lint::Lint`.
230+ /// }
231+ /// ```
213232pub fn match_path ( path : & Path , segments : & [ & str ] ) -> bool {
214233 path. segments
215234 . iter ( )
You can’t perform that action at this time.
0 commit comments