emilk / emilk/egui

`Debug` impl for `Vec2` discards important information

Open
#7,085 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

Describe the bug

Formatting a Vec2 with {:?} leads to its Debug impl to format both coordinates with {:.1}, which discards any decimal digits after the first.

https://github.com/emilk/egui/blob/a085d0b3a5a4aa70d7ca4ddedbcc9ed53c758b7b/crates/emath/src/vec2.rs#L485-L493

To Reproduce
Steps to reproduce the behavior:

  1. format!("{:?}", vec2(0.01, -0.01))
  2. "[0.0 -0.0]"

(untested)

Expected behavior

Formatting a value should not discard important information. Debug especially shouldn't be doing that.

Note that the Display impl does not have this problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect crates/emath/src/vec2.rs at the referenced lines 485-493, then reproduce the issue with format!("{:?}", vec2(0.01, -0.01)). Done means the Debug output no longer discards important decimal digits, while the existing Display behavior remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.