Coder Social home page Coder Social logo

Comments (5)

sunshowers avatar sunshowers commented on July 17, 2024 1

Mmmmaaaaayyybbeee? The problem is that we have a workspace with a bunch of different subcrates that all have their own thiserror enums. I've added an error type to that enum, but still need to call map_err to create that other error type. Not sure how I would do it in a more seamless way. (It totally works as is so I'll probably just leave it until a possible try_from appears.

Ah, hmm, yeah. One way might be to define a crate + error type that sits at the bottom of your dependency graph, have it return an error, then use thiserror's automatic From conversion. But that's probably messier than just solving it in camino.

I do agree that solving this is probably worth it, and I'm inclined to pursue the TryFrom solution -- I think it'll likely work. I'll leave this open for a bit for more feedback from other users.

from camino.

sunshowers avatar sunshowers commented on July 17, 2024 1

This will be fixed in 1.0.3, which is about to go out to crates.io. Thanks for the report!

from camino.

sunshowers avatar sunshowers commented on July 17, 2024 1

And released :)

from camino.

sunshowers avatar sunshowers commented on July 17, 2024

Hey, thanks for the report and for checking out camino!

So I went back and forth on the definition of this for a while, eventually settling on matching OsString::into_string (which is morally equivalent to this method). However, I do see the argument for having a proper error type with the option of converting it into a PathBuf. It's too late to change the definition of from_path_buf itself now, but one could in principle add a different method -- perhaps a TryFrom<PathBuf> for Utf8PathBuf impl -- which returns an error type. What do you think? Would love some more feedback about this approach.

For your use case, do you think you could write your own freestanding function (or extension trait) for now which wraps Utf8PathBuf::from_path_buf + map_err into your own error type?

from camino.

EverlastingBugstopper avatar EverlastingBugstopper commented on July 17, 2024

I actually reached for try_from initially so I think that makes total sense!

For your use case, do you think you could write your own freestanding function (or extension trait) for now which wraps Utf8PathBuf::from_path_buf + map_err into your own error type?

Mmmmaaaaayyybbeee? The problem is that we have a workspace with a bunch of different subcrates that all have their own thiserror enums. I've added an error type to that enum, but still need to call map_err to create that other error type. Not sure how I would do it in a more seamless way. (It totally works as is so I'll probably just leave it until a possible try_from appears.

from camino.

Related Issues (15)

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.