From bab7ffe22b0fd592fb6b213ad249133b669e3e7e Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Tue, 24 Jan 2023 01:31:13 -0800 Subject: [PATCH] Add comment explaining why unsafe is used --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index a1d265d..a46c800 100644 --- a/main.go +++ b/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 { + // 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)) }