Hacker News new | ask | show | jobs
by pitdicker 942 days ago
You are right. POSIX specifies one thing, the standard library in Rust and some other libraries specifies something different. 'Safe to use unless there are other threads' is not really something you can or want to encode in a type system.

But libraries and users are caught in the middle.

1 comments

It is safe to use the Rust standard library interface.
Unless the environment is also touched by a part of the program written in Go, Julia, I don't know... The lock is not shared across languages.
> The lock is not shared across languages.

Which just to be clear: it cannot without changing the standard. There is really nothing anyone can do without a change in the standard.

However, to access any of those languages from rust you need to use unsafe.
There is no safe way to access the environment, even if you mark this API unsafe, what are you going to do?
You can safely access the environment so long as you use the rust apis and don't have unsafe code that calls `setenv` without synchronization.