Browse Source

reflect: add Addr()

pull/3511/head
Damian Gryski 2 years ago
committed by Damian Gryski
parent
commit
79930a209c
  1. 10
      src/reflect/value.go

10
src/reflect/value.go

@ -217,7 +217,15 @@ func (v Value) CanAddr() bool {
} }
func (v Value) Addr() Value { func (v Value) Addr() Value {
panic("unimplemented: (reflect.Value).Addr()") if !v.CanAddr() {
panic("reflect.Value.Addr of unaddressable value")
}
return Value{
typecode: pointerTo(v.typecode),
value: unsafe.Pointer(&v.value),
flags: v.flags ^ valueFlagIndirect,
}
} }
func (v Value) CanSet() bool { func (v Value) CanSet() bool {

Loading…
Cancel
Save