summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/internal/unsafe.go
blob: 4bc79701f4956b54d640e0f0a494cdafeeea2680 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// +build !appengine

package internal

import "unsafe"

// String converts byte slice to string.
func String(b []byte) string {
	return *(*string)(unsafe.Pointer(&b))
}

// Bytes converts string to byte slice.
func Bytes(s string) []byte {
	return *(*[]byte)(unsafe.Pointer(
		&struct {
			string
			Cap int
		}{s, len(s)},
	))
}