#406·anyhow

Increase or remove `ensure` `Debug` output limit

Author: sirewixCreated Feb 14, 2025Updated Feb 14, 2025

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