Skip to content

Doc idea: Describe which Rust constructs use pointer indirections and which memcpy #576

Closed
@kornelski

Description

@kornelski

I've realized I don't have intuition about how Rust's constructs like Slices and Vecs are laid out in memory, and thus how much of them are inline in structs, how much can be on stack, how much gets copied around.

I've seen mentions how many fields slices and vectors have, but that's not quite enough to visualize how, e.g. Option<Box<Vec<T>>> looks like.

Slices are passed to functions as &[T], but does &[&[T]] make sense? Should it be [[T]]?

I'd love to see some diagrams that show how many pointer indirections are involved in usage of complex types.

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