Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Recursive type, box?

Ook bekend als: recursive type · box (Rust)

Definition 7.9 University Computer Science — Year 2 · Hoofdstuk 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.
Lees in het hoofdstuk →