File tree 1 file changed +20
-1
lines changed 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> {
190
190
}
191
191
}
192
192
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`.
194
197
///
195
198
/// # Examples
196
199
/// ```rust,ignore
@@ -210,6 +213,22 @@ pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool {
210
213
}
211
214
}
212
215
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
+ /// ```
213
232
pub fn match_path ( path : & Path , segments : & [ & str ] ) -> bool {
214
233
path. segments
215
234
. iter ( )
You can’t perform that action at this time.
0 commit comments