Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Recursive type, box?

Também chamado de: 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.
Ler no capítulo →