." Does this mean anything other than "things like...">

What does `Vec <T>` mean?

The book of rust sometimes says things like "here we want Vec<T>."

Does this mean anything other than "things like Vector?" Also, how would you pronounce this - "vec tee"?

+4
source share
2 answers

Vec<T>means "vector of elements. Elements are of type T". Let it unpack a little ...

A vector is a data structure containing zero or more elements of the same type. Elements have an order, and you can access the elements by index (0, 1, ...). You can add and remove items. The items themselves are stored in an adjacent area allocated by the heap.

T . , , , . MyThing :

struct MyThing<T> {
    thing: T,
}

T , <>. T, S Z MyLittlePony. T . , .

, T , x foo - , .

"vec tee" "vec of tee", .

+8

Vec<T> - , , T. . vectors generics .

+2

Source: https://habr.com/ru/post/1589452/


All Articles