Automatic referencing and dereferencing

fn largest(list: &[i32]) -> i32 {
    let mut largest = list[0];
    for &item in list {
        if item > largest {
            largest = item;

Third row, the "item" type here is &i32, why does the type change to i32 after using the reference symbol, instead of &&i32 as expected?Shouldn't you use [*] for dereferencing?

Patterns Are Not Expressions

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.