Code Monkey home page Code Monkey logo

Comments (1)

shepmaster avatar shepmaster commented on July 17, 2024 2

From @BurntSushi:

One thing that might help is being super clear in the docs what exactly is generated. I (stupidly, in retrospect) kept trying to call fail on a context selector that had a source field. After thinking about it and more careful reading, I realized that was a nonsensical operation. The generics on the context selector also threw me off, but once I embraced it, I realized it was a nice ergonomic improvement that saved me from having to write some convenience constructors. All this info is in your guide, but it took a few careful read throughs to grok it all.

I haven't finished converting ripgrep yet, so I'll probably have more feedback once it's done, but I've hit two things so far:

  1. It seems tricky or impossible to define a recursive error type. If you basically try source: Box<MyError>, then you get an error saying it doesn't impl Borrow. You can add that impl, but context selectors don't really seem to work. (I'm on mobile now, so I can't elaborate on my use case. There are usually alternative designs that don't require a directly recursive error type, but they usually entail making more types.)

  2. Sometimes I just want to manually construct an error variant with a source error (e.g., collecting a Vec<MyError>), and doing that is a little weird today since you have to do Context { .. }.into(). Might be nice to have a constructor (like fail) that accepts the source error (unlike fail) on the context selector itself.

from snafu.

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.