3 ms·
Why isn't there a close method? It seems strange to omit this, given that close can return an error. edit: also closing stdin/stdout is common.
by ridiculous_fish 7y ago
Why isn't there a close method? It seems strange to omit this, given that close can return an error.
edit: also closing stdin/stdout is common.
- empath75 7y agoIt automatically closes once it’s out of scope.
- winstonewert 7y agoYou can see here some discussion of that question: https://github.com/rust-lang/rust/issues/32255 https://github.com/rust-lang/rust/issues/32255 https://github.com/rust-lang/rust/issues/59567 https://github.com/rust-lang/rust/issues/59567
- ChrisSD 7y agoThere's a sync_all method that will make sure all data and metadata is written or else return an error. This may be used at any time, not just when closing the file, and it is expensive so it does make sense to have a separate method for that case.