Skip to content

Libstd overview docs call slices "references to arrays" #23632

Closed
@tomjakubowski

Description

@tomjakubowski

The common container type, Vec, a growable vector backed by an array, lives in the vec module. References to arrays, &[T], more commonly called "slices", are built-in types for which the slice module defines many methods.

I think that in modern Rust parlance [T] is a slice and &[T] is a "borrowed slice" (hooray DST). Moreover, if [T; n] is an "array" then a borrowed slice may be a reference to some contiguous region that isn't backed by an array. This might seem pedantic but I think it's important to be clear that &[T] may not actually point to an array.

My suggested rewording would be:

Contiguous, unsized regions of memory, [T], commonly called "slices", and their borrowed versions, &[T], commonly called "borrowed slices", are built-in types for which the ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions