From ace08d6e6ec3a409fa155223cc67eece6f665937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 25 Feb 2025 00:03:52 +0900 Subject: [PATCH] feat(item): add api Pointer --- item.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/item.go b/item.go index 07b5a5e..2d0f3db 100644 --- a/item.go +++ b/item.go @@ -46,6 +46,14 @@ func (b *Item[T]) Unwrap() T { return b.val } +// Pointer use pointer value of the item +func (b *Item[T]) Pointer() *T { + if b.stat.hasdestroyed() { + panic("use after destroy") + } + return &b.val +} + // Ref gens new item without ownership. // // It's a safe reference, thus calling this