Skip to content

Explain when temporary 'anonymous' values will be dropped #850

Closed
@PieterPenninckx

Description

@PieterPenninckx

After reading reading The Book, readers get an idea when named variables are being dropped. For temporary values (which I tend to call 'anonymous values') however, I couldn't find any part in The Book that indicates when these are dropped.

When I didn't know when temporaries will be dropped, I used my intuition to fill the gap in my knowledge. Because my intuition was incorrect, I could have written code that does not behave as I would expect. An example of how this can lead to bugs can be found in rust-lang/rust#37612. For this reason, I think it is worth mentioning when temporaries are dropped.

The reference includes a section explaining when temporary values will be dropped.

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