bytes.Copy

R=rsc
DELTA=38  (38 added, 0 deleted, 0 changed)
OCL=29895
CL=29895
This commit is contained in:
Rob Pike 2009-06-04 15:00:15 -07:00
parent 78933226f1
commit 52e5d061c7
4 changed files with 38 additions and 0 deletions

View file

@ -41,6 +41,15 @@ func Equal(a, b []byte) bool {
return true
}
// Copy copies the source to the destination, stopping when the source
// is all transferred. The caller must guarantee that there is enough
// room in the destination.
func Copy(dst, src []byte) {
for i, x := range src {
dst[i] = x
}
}
// Explode splits s into an array of UTF-8 sequences, one per Unicode character (still arrays of bytes).
// Invalid UTF-8 sequences become correct encodings of U+FFF8.
func Explode(s []byte) [][]byte {