ITADN

utils/vector: `Slice()` method is broken

#492Opengucio321 创建于 2025-11-05
G
gucio321commented
```go // Slice converts a Vector to a slice []T. func (v Vector[T]) Slice() []T { // We consider v.Data a pointer to 1st element of a slice []T // of size v.Size and capacity v.Capacity return unsafe.Slice(v.Data, v.Size) } ``` The problem is, that in most Vector implementations `T` is supposed to be a pointer to the Go-wrapped type, so converting it to the C slice makes no sense (and causes issues). this should either refer to `v.Data.CData` or make `T` a C type pointer (need to design this somehow)
5 条评论