common.go 477 B

12345678910111213141516
  1. package opencost
  2. // Pair is a generic struct containing a pair of instances, one of each type similar to std::pair
  3. type Pair[T any, U any] struct {
  4. First T
  5. Second U
  6. }
  7. // Creates a new pair struct containing the provided parameters. This is useful for creating types
  8. // capable of representing common paired types (result, error), (result, bool), etc...
  9. func NewPair[T any, U any](first T, second U) Pair[T, U] {
  10. return Pair[T, U]{
  11. First: first,
  12. Second: second,
  13. }
  14. }