mirror of
https://github.com/golang/go
synced 2024-11-25 02:27:56 -07:00
exp/iterable: add UintArray
all other basic types seem to be represented. R=rsc CC=golang-dev https://golang.org/cl/1919042
This commit is contained in:
parent
8c5f30c0d9
commit
8055f47029
@ -57,3 +57,16 @@ func (a StringArray) Iter() <-chan interface{} {
|
||||
}()
|
||||
return ch
|
||||
}
|
||||
|
||||
type UintArray []uint
|
||||
|
||||
func (a UintArray) Iter() <-chan interface{} {
|
||||
ch := make(chan interface{})
|
||||
go func() {
|
||||
for _, e := range a {
|
||||
ch <- e
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
return ch
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ func TestArrayTypes(t *testing.T) {
|
||||
if x := Data(bytes)[1].(byte); x != 2 {
|
||||
t.Error("Data(bytes)[1].(byte) = %v, want 2", x)
|
||||
}
|
||||
uints := UintArray([]uint{1, 2, 3})
|
||||
if x := Data(uints)[1].(uint); x != 2 {
|
||||
t.Error("Data(uints)[1].(uint) = %v, want 2", x)
|
||||
}
|
||||
ints := IntArray([]int{1, 2, 3})
|
||||
if x := Data(ints)[2].(int); x != 3 {
|
||||
t.Error("Data(ints)[2].(int) = %v, want 3", x)
|
||||
|
Loading…
Reference in New Issue
Block a user