You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every function current passes in AsFd by value. This is safe, but a little weird because you can do read(owned_fd, ...) and close the fd within the read call. Was this considered? Or a design mistake?
The text was updated successfully, but these errors were encountered:
Earlier versions of rustix did pass the AsFd by reference, and it was changed to pass it by value.
This makes it work more like AsRef<Path>, which is typically passed by value rather than by reference.
Users were writing code passing AsFd by value even when rustix and io-lifetimes and all the docs demonstrated it by passing it by reference, which suggested that passing by value was the more intuitive way.
Passing by value means users need fewer &s.
The fact that it can cause an owning type to be dropped was considered. It is a little surprising, but if you intend to use the owned type for anything afterwards, you'll get a compiler error, rather than a runtime surprise, so it seemed an ok tradeoff.
Every function current passes in
AsFd
by value. This is safe, but a little weird because you can doread(owned_fd, ...)
and close the fd within the read call. Was this considered? Or a design mistake?The text was updated successfully, but these errors were encountered: