Skip to content

[rustdoc]A wrong in documents about slice #45678

Closed
@qingzhu521

Description

@qingzhu521

https://doc.rust-lang.org/std/primitive.slice.html
I think that in let x = &mut [1, 2, 3];, x is not slice. It is just a reference for primitive type (arrary)
for example:

let intarr_slice = &[&[1,2][..],&[3,4,5][..]];
let intarr_slice2 = &[&[1,2],&[3,4,5]];

that the second on is not a right statements.
against the definition of let str_slice: &[&str] = &["one", "two", "three"];
x = &mut[1,2,3][..] is slice type.

And I think it's better to add a note.

let x = [1,2,3];
let y = &x[..];

and

let x = &[1,2,3];
let y = &x[..];

these y are same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions