]> Cypherpunks repositories - gostls13.git/commit
allow direct conversion between string and named []byte, []rune
authorRuss Cox <rsc@golang.org>
Tue, 22 Nov 2011 17:30:02 +0000 (12:30 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 22 Nov 2011 17:30:02 +0000 (12:30 -0500)
commit6e3e3809231c71fc30b6d0cdcb1f60c5e6e816ef
treee1e48c198bc31ca4fe901fac630758382db1151c
parentc69d6345daf277b947341ba958458b0a500effe1
allow direct conversion between string and named []byte, []rune

The allowed conversions before and after are:
        type Tstring string
        type Tbyte []byte
        type Trune []rune

        string <-> string  // ok
        string <-> []byte  // ok
        string <-> []rune // ok
        string <-> Tstring // ok
        string <-> Tbyte // was illegal, now ok
        string <-> Trune // was illegal, now ok

        Tstring <-> string  // ok
        Tstring <-> []byte  // ok
        Tstring <-> []rune // ok
        Tstring <-> Tstring // ok
        Tstring <-> Tbyte // was illegal, now ok
        Tstring <-> Trune // was illegal, now ok

Update spec, compiler, tests.  Use in a few packages.

We agreed on this a few months ago but never implemented it.

Fixes #1707.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5421057
doc/go_spec.html
src/cmd/gc/subr.c
src/pkg/encoding/xml/xml_test.go
src/pkg/net/http/sniff.go
src/pkg/net/mail/message.go
test/convert1.go [new file with mode: 0644]
test/convlit.go
test/named1.go