// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

package cast

import (
	
)

// From html/template/content.go
// Copyright 2011 The Go Authors. All rights reserved.
// indirect returns the value, after dereferencing as many times
// as necessary to reach the base type (or nil).
func indirect( any) (any, bool) {
	if  == nil {
		return nil, false
	}

	if  := reflect.TypeOf(); .Kind() != reflect.Ptr {
		// Avoid creating a reflect.Value if it's not a pointer.
		return , false
	}

	 := reflect.ValueOf()

	for .Kind() == reflect.Ptr || (.Kind() == reflect.Interface && .Elem().Kind() == reflect.Ptr) {
		if .IsNil() {
			return nil, true
		}

		 = .Elem()
	}

	return .Interface(), true
}