Comments (5)
Welp ... upon closer inspection I realized that most functions in dirs
return Option
already. :-/
So I guess there is pretty much no point in trying to retain the few PathBuf
-returning functions over using Option<PathBuf>
everywhere.
from dirs-rs.
It looks like the better question to ask is whether returning Option<PathBuf>
is actually sufficient for functions that rely on home_dir
, or if it is more reasonable to use Result
to differentiate between errors caused by home_dir
failing and errors caused by the function itself failing, e. g.: executable_dir
could either fail because
home_dir
failed- no executable dir exists on the platform
from dirs-rs.
I think there is no downside to using Result
as it can be easily converted to an Option
. Maybe a lightweight enum without inner type would be sufficient as the Err
variant?
from dirs-rs.
@b-r-u Thanks for the suggestion!
I also considered this, but went for Option
(for no elaborate reason) ... I'm open to changing this, although this would mean incrementing the major version to 2.0, because I already shipped 1.0 yesterday. :-/
What do you think?
from dirs-rs.
I'm not familiar with the different error conditions but if it's unlikely for users of the library to care about them then Option
would be the best option :)
from dirs-rs.
Related Issues (20)
- gcc error while testing
- Remove cfg-if HOT 2
- Windows: Add fallback for nanoserver Windows containers HOT 2
- MacOS $XDG_* HOT 1
- Add support for `XDG_STATE_HOME` HOT 1
- Windows font_dir HOT 6
- Thoughts on testing `dirs::config_dir()` on Windows? HOT 1
- Incorrect `config_dir` on Windows 10 HOT 3
- Systemd Service Directories HOT 2
- Add better descriptions as to what causes None to be returned. HOT 9
- Prefer $HOME (and XDG environment) even on Windows HOT 10
- Better Integration for Testing HOT 3
- use XDG_STATE_HOME as data_local_dir HOT 2
- Add default values for `$XDG_DOWNLOAD_DIR` and such
- (Not really a bug) option-ext used in dirs-sys adds an MPL license requirement HOT 3
- [Windows] Add user writeable fonts folder HOT 1
- Please add a crates.io co-maintainer HOT 2
- data_dir return path in macos 14.3 is wrong HOT 1
- Honor XDG variables on MacOS HOT 1
- use emojis that exist on windows 10 for the readme file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dirs-rs.