diff options
| author | Philipp Hansch <dev@phansch.net> | 2019-03-08 09:50:20 +0100 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2019-03-08 09:50:20 +0100 |
| commit | f04acdd46353322c5e9c44c85e4129083dcaf082 (patch) | |
| tree | 18fe3a0d065f8a7e352daa6021423106e735783f | |
| parent | 00baf7a1118f4b8332a47f68e8bebbac963a5dcb (diff) | |
| download | rust-f04acdd46353322c5e9c44c85e4129083dcaf082.tar.gz rust-f04acdd46353322c5e9c44c85e4129083dcaf082.zip | |
Document match_path, improve match_qpath docs
| -rw-r--r-- | clippy_lints/src/utils/mod.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 70ba0592caa..83c7d586e64 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -190,7 +190,10 @@ pub fn single_segment_path(path: &QPath) -> Option<&PathSegment> { } } -/// Match a `Path` against a slice of segment string literals. +/// Match a `QPath` against a slice of segment string literals. +/// +/// There is also `match_path` if you are dealing with a `rustc::hir::Path` instead of a +/// `rustc::hir::QPath`. /// /// # Examples /// ```rust,ignore @@ -210,6 +213,22 @@ pub fn match_qpath(path: &QPath, segments: &[&str]) -> bool { } } +/// Match a `Path` against a slice of segment string literals. +/// +/// There is also `match_qpath` if you are dealing with a `rustc::hir::QPath` instead of a +/// `rustc::hir::Path`. +/// +/// # Examples +/// +/// ```rust,ignore +/// if match_path(&trait_ref.path, &paths::HASH) { +/// // This is the `std::hash::Hash` trait. +/// } +/// +/// if match_path(ty_path, &["rustc", "lint", "Lint"]) { +/// // This is a `rustc::lint::Lint`. +/// } +/// ``` pub fn match_path(path: &Path, segments: &[&str]) -> bool { path.segments .iter() |
