]> Cypherpunks.ru repositories - gostls13.git/commit
reflect: add MapIter.SetKey and MapIter.SetValue
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 17 May 2021 19:31:11 +0000 (12:31 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 24 Aug 2021 22:23:12 +0000 (22:23 +0000)
commit54cdef1f101a7a15fa6412fbedf8b009a1f725a1
treecf09d86e38c27940a295118ddbcf79397acaa19d
parent5d863f89fed8f0580294ada88f92f72f361c598f
reflect: add MapIter.SetKey and MapIter.SetValue

These augment the existing MapIter.Key and MapIter.Value methods.
The existing methods return new Values.
Constructing these new Values often requires allocating.
These methods allow the caller to bring their own storage.

The naming is somewhat unfortunate, in that the spec
uses the word "element" instead of "value",
as do the reflect.Type methods.
In a vacuum, MapIter.SetElem would be preferable.
However, matching the existing methods is more important.

Fixes #32424
Fixes #46131

Change-Id: I19c4d95c432f63dfe52cde96d2125abd021f24fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/320929
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/reflect/all_test.go
src/reflect/value.go