Box<T>
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Box<T> e vendos një vlerë në heap dhe mban një pointer drejt saj. Përdoret për tipe rekursive (si pemët) dhe për objekte trait (Box<dyn Trait>). Lirohet vetë kur Box-i del nga blloku.
EnglishEN
Box<T> puts a value on the heap and holds a pointer to it. It's used for recursive types (like trees) and trait objects (Box<dyn Trait>). It's freed automatically when the Box goes out of scope.
Si ta mendosh
Si ta ruash diçka të madhe në depo dhe të mbash vetëm çelësin në xhep.
Lexoje në anglisht
Like storing something big in a storage unit and keeping just the key in your pocket.
Shembull kodirust
enum Lista { Nyje(i32, Box<Lista>), Fund }
let l = Lista::Nyje(1, Box::new(Lista::Nyje(2, Box::new(Lista::Fund))));