mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola bors r+ Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
c96481e25f
5 changed files with 8 additions and 11 deletions
|
@ -21,8 +21,7 @@ pub(super) fn parse_intra_doc_link(s: &str) -> (&str, Option<hir::Namespace>) {
|
|||
(hir::Namespace::Values, (VALUES.0.iter(), VALUES.1.iter())),
|
||||
(hir::Namespace::Macros, (MACROS.0.iter(), MACROS.1.iter())),
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.find_map(|(ns, (mut prefixes, mut suffixes))| {
|
||||
if let Some(prefix) = prefixes.find(|&&prefix| {
|
||||
s.starts_with(prefix)
|
||||
|
@ -42,8 +41,7 @@ pub(super) fn strip_prefixes_suffixes(s: &str) -> &str {
|
|||
(VALUES.0.iter(), VALUES.1.iter()),
|
||||
(MACROS.0.iter(), MACROS.1.iter()),
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.find_map(|(mut prefixes, mut suffixes)| {
|
||||
if let Some(prefix) = prefixes.find(|&&prefix| {
|
||||
s.starts_with(prefix)
|
||||
|
|
|
@ -226,7 +226,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def>
|
|||
|
||||
Some(
|
||||
[Direction::Prev, Direction::Next]
|
||||
.iter()
|
||||
.into_iter()
|
||||
.flat_map(|dir| {
|
||||
parent_use_item_syntax
|
||||
.siblings(dir.to_owned())
|
||||
|
|
|
@ -105,7 +105,7 @@ fn generate_lint_descriptor(buf: &mut String) {
|
|||
|
||||
fn generate_feature_descriptor(buf: &mut String, src_dir: &Path) {
|
||||
let mut features = ["language-features", "library-features"]
|
||||
.iter()
|
||||
.into_iter()
|
||||
.flat_map(|it| sourcegen::list_files(&src_dir.join(it)))
|
||||
.filter(|path| {
|
||||
// Get all `.md ` files
|
||||
|
|
|
@ -43,8 +43,7 @@ impl Sysroot {
|
|||
// core is added as a dependency before std in order to
|
||||
// mimic rustcs dependency order
|
||||
["core", "alloc", "std"]
|
||||
.iter()
|
||||
.copied()
|
||||
.into_iter()
|
||||
.zip(iter::repeat(true))
|
||||
.chain(iter::once(("test", false)))
|
||||
.filter_map(move |(name, prelude)| Some((name, self.by_name(name)?, prelude)))
|
||||
|
@ -78,7 +77,7 @@ impl Sysroot {
|
|||
for path in SYSROOT_CRATES.trim().lines() {
|
||||
let name = path.split('/').last().unwrap();
|
||||
let root = [format!("{}/src/lib.rs", path), format!("lib{}/lib.rs", path)]
|
||||
.iter()
|
||||
.into_iter()
|
||||
.map(|it| sysroot.root.join(it))
|
||||
.filter_map(|it| ManifestPath::try_from(it).ok())
|
||||
.find(|it| fs::metadata(it).is_ok());
|
||||
|
|
|
@ -212,8 +212,8 @@ impl Server {
|
|||
if req.method == "client/registerCapability" {
|
||||
let params = req.params.to_string();
|
||||
if ["workspace/didChangeWatchedFiles", "textDocument/didSave"]
|
||||
.iter()
|
||||
.any(|&it| params.contains(it))
|
||||
.into_iter()
|
||||
.any(|it| params.contains(it))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue