summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unnecessary_join.rs
blob: 0a21656a7558e3fb40c826c7de1c7f376ccecf09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// run-rustfix

#![warn(clippy::unnecessary_join)]

fn main() {
    // should be linted
    let vector = vec!["hello", "world"];
    let output = vector
        .iter()
        .map(|item| item.to_uppercase())
        .collect::<Vec<String>>()
        .join("");
    println!("{}", output);

    // should be linted
    let vector = vec!["hello", "world"];
    let output = vector
        .iter()
        .map(|item| item.to_uppercase())
        .collect::<Vec<_>>()
        .join("");
    println!("{}", output);

    // should not be linted
    let vector = vec!["hello", "world"];
    let output = vector
        .iter()
        .map(|item| item.to_uppercase())
        .collect::<Vec<String>>()
        .join("\n");
    println!("{}", output);

    // should not be linted
    let vector = vec!["hello", "world"];
    let output = vector.iter().map(|item| item.to_uppercase()).collect::<String>();
    println!("{}", output);
}