top | item 45010888

(no title)

dezgeg | 6 months ago

Is that really rust-specific? I would be really surprised if any other languages do fsync() in their destructor either

discuss

order

maxbond|6 months ago

ETA: See correction below.

To be clear `File::drop()` does sync, it just ignores errors (because `drop()` doesn't have a way of returning an error). It's not really Rust specific I guess, I just don't know off the top of my head what other languages behave this way.

aw1621107|6 months ago

I believe C++'s fstreams also ignore errors on destruction for similar reasons.

I've wondered for a while what it'd take to eliminate such pitfalls in the "traditional" RAII approach. Something equivalent to deleting the "normal" RAII destructor and forcing consumption via a close() could be interesting, but I don't know how easy/hard that would be to pull off.