QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.
Apache License 2.0
386 stars 42 forks source link

Implement Error::cause() and source() for BacktraceError #113

Open tormol opened 5 months ago

tormol commented 5 months ago

I didn't notice cause() wasn't coming from the Error trait, until I passed the error to a &dyn Error-taking function and was surprised that cause() was suddenly returning None.

Is there a reason why it's implemented as an inherent method instead of as part of the Error trait? I don't think a reference to a boxed trait object lets the caller do anything more than they could with a reference to a trait object.

I've ran most of the pre-commit commands, but the --tests part of cargo test and cargo test --no-default-features fails with:

     Running test/main.rs (target/debug/deps/test-e1f5e416b5ec9618)
INFO [test] Running test issue_90_pass_text_between_threads
thread 'main' panicked at test/main.rs:97:10:
called `Result::unwrap()` on an `Err` value: NoAvailablePixelFormat

(On linux with wayland)

QuantumBadger commented 5 months ago

Thanks for submitting this. If I remember correctly, those functions in the Error trait were experimental at the time when Speedy2D was released.

In principle this looks fine, it just needs formatting with cargo +nightly fmt.