CopyTo copies each of the underlying Buffer's data into the given buffer, returning the number of bytes copied. Has the same semantics as the copy builtin in that it will copy as many bytes as it can, stopping when either dst is full or s runs out of data, returning the minimum of s.Len() and len(ds
(dst []byte)
| 77 | // builtin in that it will copy as many bytes as it can, stopping when either dst |
| 78 | // is full or s runs out of data, returning the minimum of s.Len() and len(dst). |
| 79 | func (s BufferSlice) CopyTo(dst []byte) int { |
| 80 | off := 0 |
| 81 | for _, b := range s { |
| 82 | off += copy(dst[off:], b.ReadOnlyData()) |
| 83 | } |
| 84 | return off |
| 85 | } |
| 86 | |
| 87 | // Materialize concatenates all the underlying Buffer's data into a single |
| 88 | // contiguous buffer using CopyTo. |