GithubHelp home page GithubHelp logo

Comments (4)

dot-asm avatar dot-asm commented on August 25, 2024

If instead ...

Does it have to be "instead"? I mean what prevents us from just adding it? Not that I have some attachment to From, it's just that yanking it is likely to be considered bad style. You kind of add something new and remove old later...

If I should provide a pull request, let me know.

If it's just Display, I can handle it. But maybe there is more to it. Say it might be appropriate to implement Error trait. In other words if you can think of something more nuanced than adding Display, then a pull request would be appreciated. Well, it would be appreciated in either case, but we do need our Rust exercises too, you know :-)

from sppark.

vmx avatar vmx commented on August 25, 2024

Does it have to be "instead"? I mean what prevents us from just adding it?

You're right. Display could just be added, you can keep the From<Error> for String implementation.

If it's just Display, I can handle it. But maybe there is more to it.

Indeed the "proper" way would be to also implement the Error trait.

Well, it would be appreciated in either case, but we do need our Rust exercises too, you know :-)

Then I'd take a look at https://crates.io/crates/thiserror. This is a simple macro that generates the code you'd otherwise create manually. This would then also implement Dsiplay.

One thing I don't fully understand is, why the CUDA error is wrappen in a macro. Why not just having it as a normal struct and importing it whenever you want to use it?

from sppark.

dot-asm avatar dot-asm commented on August 25, 2024

I've added Display, simplified for now as Error needs an overhaul. Because we've discussed using it for conveying errors other than CUDA.

One thing I don't fully understand is, why the CUDA error is wrappen in a macro.

The original rationale was that we don't know if it will be needed (because target application might not be using CUDA code), and providing a macro would give the application freedom to decide. But since it's discussed to be used for other errors, it's arguably appropriate to change that...

from sppark.

vmx avatar vmx commented on August 25, 2024

Thanks a lot for implementing Display, it's kind of nicer to be able to call .to_string().

from sppark.

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.