Skip to content

Finalisation and disposing of resources using deferred blocks

Yorick Peterse requested to merge defer-blocks into master

The method std::process.defer can be used to schedule a block for execution when the calling scope returns, even when a panic is triggered. Such blocks are useful when cleaning up resources, such as files and sockets.

This will be used in !14 (merged) and the tests for std::fs::dir, ensuring tests clean up their data, even in the event of a panic.

Edited by Yorick Peterse

Merge request reports