Closed
Description
(copying my comment from #46131 (comment) to avoid it being forgotten for the 1.18 release)
Bikeshed: I was a little confused by the direction of setting. In reflect
, we have:
func (v Value) Set(x Value)
func (v Value) SetBool(x bool)
func (v Value) SetBytes(x []byte)
func (v Value) SetCap(n int)
func (v Value) SetComplex(x complex128)
func (v Value) SetFloat(x float64)
func (v Value) SetInt(x int64)
func (v Value) SetLen(n int)
func (v Value) SetMapIndex(key, elem Value)
func (v Value) SetPointer(x unsafe.Pointer)
func (v Value) SetString(x string)
func (v Value) SetUint(x uint64)
All of these store a value into the receiver v
from the input argument.
Now we added:
func (it *MapIter) SetKey(dst Value)
func (it *MapIter) SetValue(dst Value)
However, contrary to reflect.Value.SetXXX
, a value is being stored into the input argument from state in the receiver it
. It is the opposite direction.
Perhaps we should rename it as SetKeyInto
and SetValueInto
? Or StoreKey
and StoreValue
(per @josharian's suggestion)?
\cc @rsc @randall77