Comments (9)
I've created a repository at https://github.com/tylerreisinger/approx_derive to implement it. When it is production ready, I can transfer ownership or merge it into the approx repo with a cargo workspace.
from approx.
@joshburkart It's not ready for a PR yet, but I can work on it a bit this weekend and see if I can get something working. TryFrom being stabilized helps with an issue implementing it.
from approx.
Is the last blanket impl necessary? You could always just create a macro to create the implementation for foreign types if needed
from approx.
Here's a pretty quick and dirty example of the sort of thing needed: https://gist.github.com/tylerreisinger/886e56379beffabddaff7bad6a232f06. It can only handles structs and won't insert type bounds on generics, but otherwise works.
from approx.
Also, there is no clean way to deal with both non-primitive Epsilon types and a mix of f32/f64 types without TryFrom, which is currently unstable. I used as
in my example, as I'm guessing non-primitive Epsilons aren't that common.
from approx.
A nice thing to have would be a derive-proc-macro, so you could do
#[derive(AbsDiffEq)]
struct MyStruct { ... }
thus avoiding all the repetitive boilerplate on a per-struct basis.
from approx.
This would be really great to have! Approximately comparing nested struct
s/enum
s is a pretty common use case when writing tests for numerical computing applications. @tylerreisinger Do you think the implementation you made is ready for a PR in some form? Or too hacky right now?
from approx.
Yeah, having this would be really nice! I know it'll be a bit annoying with the epsilon though, and haven't had much time at the moment to look into it.
from approx.
I'd love to have this as well!
from approx.
Related Issues (20)
- Adding messages to assert_* macros HOT 2
- Release another version HOT 2
- Overflow on absolute comparison of signed integers HOT 3
- Not working at all? HOT 3
- Improve Documentation HOT 2
- Support for slices? HOT 4
- Please tag releases HOT 1
- Unecessary std feature HOT 1
- relative_eq() has incorrect behavior for small values HOT 3
- Release a 1.0 version HOT 3
- Inconsistent temporary value behavior with `assert_eq!`
- clippy::if_then_panic warning (nightly) HOT 3
- Maintenance status HOT 3
- Transferral of repository HOT 1
- Give acceptable range on assertion failure
- Changelog for version updates would be nice
- `impl RelativeEq for Option<T: RelativeEq>`? HOT 1
- `assert_relative_eq!()` fails in compilation
- impl RelativeEq for NotNan and OrderedFloat from ordered_float
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from approx.