package unsafecast
Import Path
github.com/parquet-go/parquet-go/internal/unsafecast (on go.dev)
Dependency Relation
imports one package, and imported by 11 packages
Involved Source Files
Package unsafecast exposes functions to bypass the Go type system and perform
conversions between types that would otherwise not be possible.
The functions of this package are mostly useful as optimizations to avoid
memory copies when converting between compatible memory layouts; for example,
casting a [][16]byte to a []byte in order to use functions of the standard
bytes package on the slices.
With great power comes great responsibility.
Package-Level Functions (total 2)
Type Parameters:
To: any
From: any
Slice converts the data slice of type []From to a slice of type []To sharing
the same backing array. The length and capacity of the returned slice are
scaled according to the size difference between the source and destination
types.
Note that the function does not perform any checks to ensure that the memory
layouts of the types are compatible, it is possible to cause memory
corruption if the layouts mismatch (e.g. the pointers in the From are
different than the pointers in To).
String converts a byte slice to a string value. The returned string shares
the backing array of the byte slice.
Programs using this function are responsible for ensuring that the data slice
is not modified while the returned string is in use, otherwise the guarantee
of immutability of Go string values will be violated, resulting in undefined
behavior.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |