dtolnay / dtolnay/anyhow

Increase or remove `ensure` `Debug` output limit

Open
#406 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
6.7k
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Currently the limit is set to 40 bytes in #195, there are few issues with that:

1. Unpredictability. I discovered this trying to figure out why in some cases I don't get useful information during test failures, while in other cases I do. This is inconsistent
2. 40 bytes is only useful when comparing numbers, for real use cases that will very often be not enough. Something like 400 bytes would suffice I guess
3. The initial argument
> This avoids dumping enormous objects into the error message implicitly.

Does not make *that* much sense:
* `assert_eq` doesn't have that limitation
* `ensure` is used primarily in tests, having a bit of a spill there wouldn't hurt, while not getting useful information actually might hurt

So I wonder if this limit can be completely removed.

On the contrary, the difference with `assert_eq` is that with `ensure` the memory needs to be allocated, while with `assert_eq` it probably prints right away, so some limit probably makes sense for this reason

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.