gust
gust copied to clipboard
Implementation question: Option's secondary pointer
trafficstars
I have a question, why does the implementation of Option use a second level pointer? I have reviewed the implementation of the relevant methods, can using a first level pointer also meet the requirements?
May I ask how the design was considered at that time?
I seem to understand a bit.
func TestZweix(t *testing.T) {
type F struct {
A int
B string
}
opt1 := gust.Some[*F](&F{A: 1, B: "2"})
opt2 := gust.Some[*F](nil)
}
To identify such scenarios.