GithubHelp home page GithubHelp logo

Comments (16)

withoutboats avatar withoutboats commented on June 27, 2024 2

The crate name is failure. The derive crate will probably be renamed failure_derive since this is the most common naming scheme for derive crates.

from failure.

withoutboats avatar withoutboats commented on June 27, 2024 1

This is the only issue opened so far that would be a breaking change to follow up on after the 0.1 release, so its the one we need to hash out ASAP. If you have alternative names, speak now or forever hold your peace. :-)

from failure.

DorianListens avatar DorianListens commented on June 27, 2024 1

I’m a fan of both Fail and Error, for what it’s worth. I think the naming guidelines are worth following for consistency if nothing else, and the confusion over Error is probably worth it to simplify the common case.

from failure.

m4b avatar m4b commented on June 27, 2024 1

This is somewhat related but do you plan to use - or underscore in crate name (for derive) ?

Also I thought derive_fail was unusual (as opposed to fail_derive)

Also the crate will be named failure or fail?

from failure.

troiganto avatar troiganto commented on June 27, 2024 1

Just throwing this out, but since the main purpose of the trait in question seems to be to universally 'cast' any error to the failure::Error type, would IntoError be a fitting name? The name seems to have some precedent in the standard library (IntoIterator comes to mind).

from failure.

troiganto avatar troiganto commented on June 27, 2024 1

That's a fair point. FWIW, I switched the application I'm working on from quick-error to failure yesterday. The refactor was straight-forward, removed a ton of boilerplate, and and all compiler warnings/errors afterwards were about missing or unused uses. So I'm very excited for the next release!

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

According to Rust's style guides, best practice is to name traits verbs (e.g. Read, Write, Display) and types nouns (e.g. Result, String, HashMap). Fail is an English verb and not intended to be a reference to a meme.

The Error struct is called Error so that the easiest thing to do is write Result<_, Error>. The transition from the current trait is unfortunate.

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

We did consider Error/AnyError as an alternative prior to publicizing this, but I'm pretty confident that would not be preferable.

from failure.

HadrienG2 avatar HadrienG2 commented on June 27, 2024

I did not know about this trait naming guideline, but it seems like in addition to being somewhat arbitrary, it does not reflect practical usage at all.

Just consider the standard library traits: you have Any, AsRef/AsMut, (Partial)Eq, Error, Fn, From/Into, Hasher, Iterator (Partial)Ord, Sized... It does seem like we did very well without the constraint that everything be a verb so far.

The convention of naming interfaces after nouns, on the other hand, has been established in the OO community for a long while, so deprecating it seems somewhat strange.

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

Its true that it hasn't been followed consistently (though "Ord[er]", "Eq[ual]" and "Error" are technically verbs). I don't even like it that much, but since it is the recommendation I'm inclined to follow it.

(more examples of it being followed: Clone, Hash, Debug, Default, almost all of the ops traits)

from failure.

HadrienG2 avatar HadrienG2 commented on June 27, 2024

Well, let's see if I'm the only one bothered by this naming convention or if others have better proposals, then. I will gladly admit to being terrible at naming things myself, it's just that for reasons described above, I have the impression that there has to be a better name for these two concepts somewhere, waiting to be found.

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

I'm open to renaming Fail if there is a better name out there, but I'm pretty committed to Error so that the obvious thing of making the Err variant of Result an Error will Just Work.

from failure.

U007D avatar U007D commented on June 27, 2024

@HadrienG2 I agree that the trait vs. struct name collision is (and will continue to be) a source of confusion (I've run into this myself in the not-too-distant past). I also agree that some of the guideline choices seem questionable.

With that, my 2¢ is in agreement with @withoutboats that the best way forward (ie. best way to not introduce yet more confusion over and above what we already have) is to adhere to the guidelines, such as they are.

from failure.

repax avatar repax commented on June 27, 2024

IIRC, the motivation for that guideline was to have short trait names, e.g. Copy instead of Copyable. Personally, I think adjectives are a better fit for traits names. Verbs makes sense for (some) functions.

from failure.

m4b avatar m4b commented on June 27, 2024

Yes please the second, had to lookup again that it was derive_fail instead of failure. It also matches serde, etc, and this way can easily see all the deriving crates at a glance

from failure.

withoutboats avatar withoutboats commented on June 27, 2024

Planning to release this tomorrow afternoon (PST, aka about 10 to 12 hours from now). Since I don't plan to make breaking changes at least for the rest of the year I'm going to close this.

Changed the name of the derive crate to failure_derive but otherwise feel pretty happy with the original names. Thanks for the discussion though.

@troiganto Sorry I forgot to reply to your comment. Fail is useful separate from Error; though returning Error is often a good idea, there are use cases in which you don't want to do that. So I don't want to suggest that the only reason to implement the trait is to cast your type into Error.

from failure.

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.