Will an array autoderef to a slice?

I'm confusing about how the following code works. It can be explained if array is autoderef to a slice , I'm not sure , can somebody confirm this for me? Many thanks.

fn main() {
  [1;10].as_mut_ptr();
}

“Arrays coerce to slices ( [T] ), so a slice method may be called on an array. Indeed, this provides most of the API for working with arrays. Slices have a dynamic size and do not coerce to arrays.”

Quoted from this page:
array - Rust.

Does that help?

1 Like

Thank you , this really help . It's a shame without reading the doc carefully :roll_eyes:

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.