Thanks to visit codestin.com
Credit goes to lib.rs

#debugging #list #range #item #sequential #adjacent #formatting #help #integer #display

dbg-ranges

Helps with debug formatting lists of items that have many sequential items

2 releases

0.1.1 Jan 23, 2025
0.1.0 Jan 22, 2025

#1291 in Algorithms


Used in 2 crates

MIT/Apache

12KB
214 lines

Debug implementations for ranges of values

This is a simple crate which helps debugging in certain scenarios. Many algorithms rely on lists of items, such as integers, and often these lists contain runs of values that are all "adjacent".

For example, a filesystem implementation might store a list of block numbers that contain the data for a particular file. If some blocks are allocated sequentially, then there may be many runs of adjacent values. For example, [42, 100, 101, 102, 103, 104, 20, 31, 32, 33, 34]. It can be helpful to display the runs as ranges, e.g. [42, 100-104, 20, 31-34]. This is more compact and can help the developer spot patterns in data more quickly.

This crate provides two types that display ranges more compactly, and functions which construct those types.

See debug_adjacent for an example.


Debugging ranges of sequential values

This is a simple crate which helps debugging in certain scenarios. Many algorithms rely on lists of items, such as integers, and often these lists contain runs of values that are all "adjacent".

For example, a filesystem implementation might store a list of block numbers that contain the data for a particular file. If some blocks are allocated sequentially, then there may be many runs of adjacent values. For example, [42, 100, 101, 102, 103, 104, 20, 31, 32, 33, 34]. It can be helpful to display the runs as ranges, e.g. [42, 100-104, 20, 31-34]. This is more compact and can help the developer spot patterns in data more quickly.

This crate provides two types that display ranges more compactly, and functions which construct those types.

No runtime deps