Documentation
¶
Overview ¶
Package typetraits provides traits that can be used to restrict behaviour.
The size of the types defined in this package is guaranteed to be zero and have no behaviour, which eliminates runtime overhead or memory misalignment concerns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoCompare ¶
type NoCompare struct {
// contains filtered or unexported fields
}
NoCompare can be embedded or nested into a struct to prevent comparison. Comparison attempts will cause a compilation error.
The size of this struct is guaranteed to be zero.
Example:
type T struct {
_ typetraits.NoCompare
}
T{} == T{} // Comparison: compilation error!
type NoCopy ¶
type NoCopy struct {
// contains filtered or unexported fields
}
NoCopy can be embedded or nested into a struct to protect against copying. Copy attempts will be flagged by the copylocks analysis in go vet.
The size of this struct is guaranteed to be zero.
Example:
type T struct {
_ typetraits.NoCopy
}
x := T{} // The initial assignment is OK.
y := x // Copy: vetting error!
Click to show internal directories.
Click to hide internal directories.