Code Monkey home page Code Monkey logo

Comments (3)

lnicola avatar lnicola commented on July 17, 2024 1

I ported some code from failure. Some remarks:

  • I was using tuple enum items, and I had to name the fields because the documentation didn't say whether they were supported or not
  • It's not obvious that the source field is mandatory (fail is nifty, though)
  • I'm somewhat worried about the size of the Results. IIRC the compiler is bad at optimizing them, and sometimes it might be better to do an allocation instead.
  • I didn't look too much into it, but I'm not sure what eager_context is about

from snafu.

shepmaster avatar shepmaster commented on July 17, 2024

the documentation didn't say whether they were supported or not

They are not, but I’m open to discussion about it. I've opened #61 to talk about it.

I should also add this fact explicitly to the docs. You do get a specific error if you try to use tuple variants though.

the source field is mandatory

It is not; but if there’s no source field you can’t use context (where would the Result::Err go?). Instead you just use ContextSelector { fields }.fail(). Can you expand a bit more on wwhat you mean by "mandatory"?

  • the size of the Results

Do you mean Result or the enum Error type? I would expect that the size of the enum is max(size-of(variants)) + 1 byte + small amount padding) if you have less than 256 variants. There is some discussion elsewhere about better supporting boxing source errors which might help a bit.

  • what eager_context is about

TL;DR, context is used with ? and eager_context is used without ?.

from snafu.

lnicola avatar lnicola commented on July 17, 2024

It is not; but if there’s no source field you can’t use context (where would the Result::Err go?). Instead you just use ContextSelector { fields }.fail(). Can you expand a bit more on wwhat you mean by "mandatory"?

I don't have anything more to add to my comment in #10 (comment). Again, I don't mind the way it works, it's just an issue I ran into because I wasn't aware of fail().

Do you mean Result or the enum Error type?

The Error enum, as the variants could presumably grow pretty large, depending on how many errors you're nesting.

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.