Add comment explaining why unsafe is used
This commit is contained in:
parent
eb6d70bc26
commit
bab7ffe22b
5
main.go
5
main.go
@ -266,6 +266,11 @@ func joinAll(c *lemmy.WSClient) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// toSubmatches converts matches coming from PCRE2 to a
|
||||||
|
// submatch array used for the template
|
||||||
func toSubmatches(s [][]string) []Submatches {
|
func toSubmatches(s [][]string) []Submatches {
|
||||||
|
// Unfortunately, Go doesn't allow for this conversion
|
||||||
|
// even though the memory layout is identical and it's
|
||||||
|
// safe, so it is done using unsafe pointer magic
|
||||||
return *(*[]Submatches)(unsafe.Pointer(&s))
|
return *(*[]Submatches)(unsafe.Pointer(&s))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user