github.com/primecitizens/pcz/std@v0.2.1/core/mark/selfpointing.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package mark
     5  
     6  // SelfPointing marks a struct field as a pointer may pointing to data inside
     7  // the same struct.
     8  //
     9  // When using, add an extra field right before the pointer whose name
    10  // MUST be "_" + <name of the pointed field>.
    11  //
    12  // For example:
    13  //
    14  //	type T struct {
    15  //		_storage mark.SelfPointing
    16  //		buf      []byte
    17  //		_foo     mark.SelfPointing
    18  //		f        *uint
    19  //
    20  //		foo     uint
    21  //		storage [1024]byte
    22  //	}
    23  //
    24  // T.buf is a slice whose first field is a pointer may be pointing
    25  // at storage, which is:
    26  //
    27  //	unsafe.Pointer(unsafe.SliceData(T.buf)) == unsafe.Pointer(&storage)
    28  type SelfPointing struct{}