Giter Club home page Giter Club logo

Comments (4)

sfackler avatar sfackler commented on July 19, 2024

Very few error types in the ecosystem implement those traits. You'll probably have a hard time with that design more broadly.

from r2d2.

OmegaJak avatar OmegaJak commented on July 19, 2024

Is that a good reason not to, though?

If you think it would harm the library in any way, then sure. But otherwise, with such a simple error type, I don't see any reason to restrict possible uses of it by not deriving.

And yes - wrapping generally isn't preferred. But sometimes it's a nice middle ground for internal code between properly embedding the contents of the error while adding context (like you ideally would in a library use case) and resorting to something like anyhow for application code.

Anyway, if you still disagree, I understand. Feel free to close and I'll work around it by embedding a to_string() of r2d2's error.

from r2d2.

sfackler avatar sfackler commented on July 19, 2024

It prevents this error type from ever including something not Clone or not PartialEq.

from r2d2.

OmegaJak avatar OmegaJak commented on July 19, 2024

Very true.

It occurred to me to check what serde does, and it doesn't implement PartialEq either. That led me to this issue with some relevant discussion: serde-rs/json#271, with one of the downstream suggestions being to use assert_matches!. This is better for all parties - ergonomic tests, good errors, and no need to derive just for tests.

Closing this issue as not planned.

from r2d2.

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.