Git Product home page Git Product logo

Comments (5)

soc avatar soc commented on June 12, 2024

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.

soc avatar soc commented on June 12, 2024

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.

b-r-u avatar b-r-u commented on June 12, 2024

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.

soc avatar soc commented on June 12, 2024

@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.

b-r-u avatar b-r-u commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.