File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,6 @@ type UserBytes[USRDAT any] struct {
1515
1616// BufferItemToBytes convert between *Buffer
1717// and Bytes.
18- //
19- // Please notice that Bytes cannnot convert back to
20- // *Buffer again.
2118func BufferItemToBytes [USRDAT any ](
2219 buf * orbyte.Item [UserBuffer [USRDAT ]],
2320) (b UserBytes [USRDAT ]) {
@@ -28,6 +25,13 @@ func BufferItemToBytes[USRDAT any](
2825 return
2926}
3027
28+ // B directly use inner buf data and USRDAT safely.
29+ func (b UserBytes [USRDAT ]) B (f func ([]byte , * USRDAT )) {
30+ b .buf .P (func (ub * UserBuffer [USRDAT ]) {
31+ f (ub .Buffer .Bytes (), & ub .DAT )
32+ })
33+ }
34+
3135// NewBytes alloc sz bytes.
3236func (bufferPool BufferPool [USRDAT ]) NewBytes (sz int ) (b UserBytes [USRDAT ]) {
3337 buf := bufferPool .p .New (sz )
You can’t perform that action at this time.
0 commit comments