rust/tests/ui/recursion/recursive-enum-box.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
490 B
Rust
Raw Normal View History

2025-04-18 00:44:11 +09:00
//@ 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 Rusts 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))),
)),
);
}