summaryrefslogtreecommitdiff
path: root/src/lib/bytes/bytes.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-06-04 15:00:15 -0700
committerRob Pike <r@golang.org>2009-06-04 15:00:15 -0700
commit314cfedbae78028a4be587b06ac78c7052bbf111 (patch)
treea1aca68b91bcee0876e890158a39b34a7f683651 /src/lib/bytes/bytes.go
parent514b8a237a580b14442ee1ff1f71af8eae25fc6d (diff)
downloadgolang-314cfedbae78028a4be587b06ac78c7052bbf111.tar.gz
bytes.Copy
R=rsc DELTA=38 (38 added, 0 deleted, 0 changed) OCL=29895 CL=29895
Diffstat (limited to 'src/lib/bytes/bytes.go')
-rw-r--r--src/lib/bytes/bytes.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/bytes/bytes.go b/src/lib/bytes/bytes.go
index fe97b0495..a64b07b74 100644
--- a/src/lib/bytes/bytes.go
+++ b/src/lib/bytes/bytes.go
@@ -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 {