3 ms·
> No current way to get the user’s home directory. std::env::home_dir() is explicitly marked as deprecated, and the documentation encourages users to rely on th
by twic 6y ago
> No current way to get the user’s home directory. std::env::home_dir() is explicitly marked as deprecated, and the documentation encourages users to rely on the dirs crate (which is currently archived on GitHub).
Yeah, this is a bit of a farce. On the one hand, it seems fair to me to not have this in the standard library - it's not something that needs special cooperation with the compiler or runtime, it's not something universal (what would it do on an embedded microcontroller?), and it doesn't matter if different crates use different implementations. On the other hand, deprecating a standard library function in favour of a crate owned by a random user seems like an unforced error.
There's discussion here:
https://www.reddit.com/r/rust/comments/ga7f56/why_dirs_and_directories_repositories_have_been/ https://www.reddit.com/r/rust/comments/ga7f56/why_dirs_and_d...
Including the fact that there is an actively maintained alternative:
https://github.com/brson/home https://github.com/brson/home
And a clue to why those repos are archived:
> I was wondering the same thing and contacted the author. He said that some people had "lost their shit" over some of the things he mentioned about rust and that to help them calm down, they will be archived until 2022.
!
- msla 6y ago> it's not something that needs special cooperation with the compiler or runtime, it's not something universal (what would it do on an embedded microcontroller?) It's filesystem access, like the open file and read file functionality, so it needs some runtime support, and all filesystem access would fail on embedded microcontrollers, so I'm not seeing why it shouldn't be in the standard library.
- AlotOfReading 6y agoPlenty of μC's have filesystems, probably the majority nowadays. They aren't necessarily running an operating system with a concept of users though. Besides, in C the file commands can be used to do non-file IO, so those functions still have a use even without a FS.
- finnthehuman 6y ago>probably the majority nowadays I'd dispute that on the grounds that a microcontroller with a filesytem is likely doing something complicated enough that it lives on a board with at least one other microcontroller that doesn't. I'll even go as far to say it's more likely that the majority of microcontrollers don't write to mutable storage other than RAM (if they have it at all) once they leave the factory.
- deleted 6y ago[deleted]
- jayd16 6y ago>what would it do on an embedded microcontroller? Throw an exception or return null?
- 0xffff2 6y agoAn odd suggestion for a language that has no exceptions and hardly any concept of null.
- jayd16 6y agoI guess I'm not being technical enough with my language. In Rust speak, I mean panic or return an empty result with an error.
- platinumrad 6y agoWow, you really got them! Your pendantry is appreciated!!