debug2 icon indicating copy to clipboard operation
debug2 copied to clipboard

Pathological behaviour on deeply nested structures

Open aDotInTheVoid opened this issue 3 years ago • 0 comments

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

aDotInTheVoid avatar Feb 25 '22 13:02 aDotInTheVoid