mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-03 18:21:16 -03:00
Rust has this annoying design where all of the syscall conveniences on File assume that it owns its fd; in particular this means that we can't easily construct File from stdin, a raw file descriptor, etc. The usual workarounds are to construct a File and then mem::forget it (this is apparently idiomatic Rust!). But this has problems of its own: for example it can't easily be used in Drop. Introduce BorrowedFdFile which wraps File with ManuallyDrop and then never drops the file (i.e. it's always forgotten). Replace some raw FDs with BorrowedFdFile.