rust/tests/ui/recursion/recursive-enum-box.rs
2025-04-21 16:16:38 +09:00

21 lines
490 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//@ 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))),
)),
);
}