about summary refs log tree commit diff
path: root/tests/ui/recursion/recursive-enum-box.rs
blob: 540b0c553603ce711637c2b209b674f364f97c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ run-pass
// A smoke test for recursive enum structures using Box<T>.
// This test constructs a linked list-like structure to exercise memory allocation and ownership.
// Originally introduced in 2010, this is one of Rust’s earliest test cases.

#![allow(dead_code)]

enum List {
    Cons(isize, Box<List>),
    Nil,
}

fn main() {
    List::Cons(
        10,
        Box::new(List::Cons(
            11,
            Box::new(List::Cons(12, Box::new(List::Nil))),
        )),
    );
}