Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More features for Float #8

Closed
cuviper opened this issue Dec 19, 2017 · 8 comments
Closed

More features for Float #8

cuviper opened this issue Dec 19, 2017 · 8 comments

Comments

@cuviper
Copy link
Member

cuviper commented Dec 19, 2017

From @bluss on March 7, 2016 15:19

If Float truly is for f32 and f64 (it should be), we can frontload it with as much features as possible.

Wishlist:

  • 'static
  • Display + Debug + LowerExp + UpperExp
  • Send + Sync

Copied from original issue: rust-num/num#178

@cuviper
Copy link
Member Author

cuviper commented Dec 19, 2017

From @AtheMathmo on November 1, 2016 8:50

I just want to second Display + Debug. This is a real pain-point for me. I have some core functions which work on Float generics and are used all over the place. If I need to debug one of these functions I have to change trait bounds all over the place to print my data structures containing generic Floats.

There are other ways around it - like writing helper functions to convert my data structures to non-generic types that implement Display + Debug. But I think it makes sense to include these in Float. If this isn't considered a breaking change and is wanted I'd be happy to put a PR in.

@cuviper
Copy link
Member Author

cuviper commented Dec 19, 2017

From @bluss on November 1, 2016 9:11

Here's a fun workaround: https://docs.rs/debugit/0.1.0/debugit/struct.DebugIt.html (Requires nightly right now, but you just use it for debugging anyway).

@cuviper
Copy link
Member Author

cuviper commented Dec 19, 2017

From @AtheMathmo on November 1, 2016 9:13

Oh neat, thanks!

@cuviper
Copy link
Member Author

cuviper commented Mar 5, 2018

I've decided to limit the clutter of breaking change issues, so they will now be tracked collectively in #47. I'm closing this issue for now as postponed but we can still discuss its merits here as needed.

@cuviper cuviper closed this as completed Mar 5, 2018
@cuviper cuviper removed this from the num-traits-0.x milestone Mar 5, 2018
@bluenote10
Copy link

What is that status of this issue?

I'm trying to fix bugs in a library that uses the Float trait everywhere, and because Debug and Display are missing debugging is quite painful (requires to propagate Debug manually basically through the entire code base).

@cuviper
Copy link
Member Author

cuviper commented Jan 25, 2020

No change.

If you need to propagate it widely, I'd suggest making your own combined trait:

trait MyFloat: Float + Debug {}
impl<T: Float + Debug> MyFloat for T {}

Maybe we could add some extended trait like this to num_traits, without changing Float itself.

@bluenote10
Copy link

If you need to propagate it widely, I'd suggest making your own combined trait:

Not so easy, I'm not the library owner and can't make the decision. Currently I'm editing all the files every time I start debugging, just to remove all the edits before opening PRs...

Maybe we could add some extended trait ...

That would be nice. On the other hand, are you aware of implementations of Float that don't implement Display and Debug? I'd guess that >99% of the use cases are f32 and f64 for which it wouldn't be a breaking change. If Float stays inconvenient, I'm most likely not the last developer losing time due to not being able to quickly debug print something, which feels like a harsh punishment of writing generic code ;).

@cuviper
Copy link
Member Author

cuviper commented Jan 27, 2020

I'd guess that >99% of the use cases are f32 and f64 for which it wouldn't be a breaking change.

Maybe so, but I'd rather not make guesses when it comes to breaking changes.

If you're able to use a nightly toolchain for debugging, the debugit crate mentioned above or the newer dbg crate both allow debug-printing without a Debug trait bound using specialization (which is why they need nightly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants