Stebalien / tempfile

Temporary file library for rust
http://stebalien.com/projects/tempfile-rs
Apache License 2.0
1.2k stars 120 forks source link

NamedTempFile: Fix infinite recursion in trait bounds #225

Closed jasonwhite closed 1 year ago

jasonwhite commented 1 year ago

Due to bug rust-lang/rust#96634, these generic bounds may cause an infinite recursion in the compiler, even in unrelated code.

This specializes the Write for &NamedTempFile<F> impl on File instead. This keeps the API the same as before the generic parameter F was added in #177, so it shouldn't break any code. If/when the compiler bug is fixed, we can switch it back to the more generic version. Very few types implement Write for &T, however. The only other one I know of is UnixStream, which probably wouldn't be used with NamedTempFile anyway (it's counterpart UnixListener is used instead).

Fixes #224.

Stebalien commented 1 year ago

Thanks!