package builder

import (
	
	
)

var (
	registry = make(map[reflect.Type]reflect.Type)
	registryMux sync.RWMutex
)
RegisterType maps the given builderType to a structType. This mapping affects the type of slices returned by Get and is required for GetStruct to work. Returns a Value containing an empty instance of the registered builderType. RegisterType will panic if builderType's underlying type is not Builder or if structType's Kind is not Struct.
func ( reflect.Type,  reflect.Type) *reflect.Value {
	registryMux.Lock()
	defer registryMux.Unlock()
	.NumField() // Panic if structType is not a struct
	registry[] = 
	 := emptyBuilderValue.Convert()
	return &
}
Register wraps RegisterType, taking instances instead of Types. Returns an empty instance of the registered builder type which can be used as the initial value for builder expressions. See example.
func (,  interface{}) interface{} {
	 := RegisterType(
		reflect.TypeOf(),
		reflect.TypeOf(),
	).Interface()
	return 
}

func ( reflect.Type) *reflect.Type {
	registryMux.RLock()
	defer registryMux.RUnlock()
	,  := registry[]
	if ! {
		return nil
	}
	return &
}

func ( reflect.Type) *reflect.Value {
	 := getBuilderStructType()
	if  == nil {
		return nil
	}
	 := reflect.New(*).Elem()
	return &