Todos los libros

Profesional

Apps Acerca de Coach Iniciar sesión Empezar a leer

Computer Science · Glosario

¿Qué es Recursive type, box?

También llamado: recursive type · box (Rust)

Definition 7.9 University Computer Science — Year 2 · Capítulo 7 — Enums, Pattern Matching and Error Handling

A recursive type has a variant or a field whose type contains the type itself. Its values must be finite, and its size must be known: the recursive field is therefore a box, Box<T>, a pointer to a value of type T on the heap that owns it and frees it when dropped.

The tree of , built by inserting 189, 65, 251, 133, 412, 98 and 320. Each arrow is a Box: the node owns its children, and dropping the root frees the whole tree. The leaves under 98 and 320 are not drawn.
The tree of Output 7.8, built by inserting 189, 65, 251, 133, 412, 98 and 320. Each arrow is a Box: the node owns its children, and dropping the root frees the whole tree. The leaves under 98 and 320 are not drawn.
Leer en el capítulo →