github.com/traefik/yaegi@v0.15.1/_test/p6/p6.go (about)

     1  package p6
     2  
     3  import (
     4  	"encoding/json"
     5  	"net/netip"
     6  )
     7  
     8  type Slice[T any] struct {
     9  	x []T
    10  }
    11  
    12  type IPPrefixSlice struct {
    13  	x Slice[netip.Prefix]
    14  }
    15  
    16  func (v Slice[T]) MarshalJSON() ([]byte, error) { return json.Marshal(v.x) }
    17  
    18  // MarshalJSON implements json.Marshaler.
    19  func (v IPPrefixSlice) MarshalJSON() ([]byte, error) {
    20  	return v.x.MarshalJSON()
    21  }