debug2
debug2 copied to clipboard
Pathological behaviour on deeply nested structures
use debug2::{pprint, Debug};
use insta::assert_snapshot;
macro_rules! check {
($e:expr) => {
assert_snapshot!(pprint($e))
};
}
#[derive(Debug)]
enum LinkedList<T> {
Empty,
Node(T, Box<LinkedList<T>>),
}
#[test]
fn linked_list_reasonable_time() {
let mut list = LinkedList::Empty;
for i in 0..10000 {
list = LinkedList::Node(i, Box::new(list));
}
check!(list);
}
thread 'linked_list_reasonable_time' has overflowed its stack