Skip to content

Stack vs. Heap documentation could use more colours #29854

Closed
@huonw

Description

@huonw

https://doc.rust-lang.org/stable/book/the-stack-and-the-heap.html includes many large tables with some connection to code, but they and the transitions between them are somewhat complicated. So one (somewhat) low-hanging fruit for improving the stack v. heap documentation would be using more colours to connect stack variables with the function they come from.

E.g. "Let’s try a three-deep example:" could look like

fn red() {
    let i = 6;
}

fn blue() {
    let a = 5;
    let b = 100;
    let c = 1;

    red();
}

fn main() {
    let x = 42;

    blue();
}

mockup

(There's a mistake in the text: "And then red() calls blue()" should be "And then blue() calls red()".)

It would be important to just use these as an extra piece, not core to the explanation, for (colour-)blind people.

Inspired/suggested by @velartrill on twitter, who also suggests using greys in a slightly different way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions