func Segment(path string, i int, v interface{}) error {  
	var err error
	switch v := v.(type) {
	case *bool:
		*v, err = segmentToBool(path, i)
	case *float32:
		var f float64
		f, err = segmentToFloatN(path, i, 32)
		*v = float32(f)
	case *float64:
		*v, err = segmentToFloatN(path, i, 64)
	case *int:
		var n int64
		n, err = segmentToIntN(path, i, 0)
		*v = int(n)
	case *int16:
		var n int64
		n, err = segmentToIntN(path, i, 16)
		*v = int16(n)
	case *int32:
		var n int64
		n, err = segmentToIntN(path, i, 32)
		*v = int32(n)
	case *int64:
		*v, err = segmentToIntN(path, i, 64)
	case *int8:
		var n int64
		n, err = segmentToIntN(path, i, 8)
		*v = int8(n)
	case *string:
		*v, err = segmentToString(path, i)
	case *uint:
		var n uint64
		n, err = segmentToUintN(path, i, 0)
		*v = uint(n)
	case *uint16:
		var n uint64
		n, err = segmentToUintN(path, i, 16)
		*v = uint16(n)
	case *uint32:
		var n uint64
		n, err = segmentToUintN(path, i, 32)
		*v = uint32(n)
	case *uint64:
		*v, err = segmentToUintN(path, i, 64)
	case *uint8:
		var n uint64
		n, err = segmentToUintN(path, i, 8)
		*v = uint8(n)
	case Unmarshaler:
		var s string
		s, err = segmentToString(path, i)
		if err == nil {
			err = v.UnmarshalSegment(s)
		}
	default:
		err = ErrUnknownType
	}
	return err
}
Segment locates the path segment indicated by the index i and unmarshals it
into the provided type v. If the index is negative, the negative count
begins with the last segment. An error is returned if: 1. The type is not a
pointer to an instance of one of the basic non-alias types and does not
implement the Unmarshaler interface; 2. The index is out of range of the
path; 3. The located path segment data cannot be parsed as the provided type
or if an error is returned when using a provided Unmarshaler implementation.
package parth
import (
	"errors"
)
type Unmarshaler interface {
	UnmarshalSegment(string) error
}
var (
	ErrUnknownType = errors.New("unknown type provided")
	ErrFirstSegNotFound = errors.New("first segment not found by index")
	ErrLastSegNotFound  = errors.New("last segment not found by index")
	ErrSegOrderReversed = errors.New("first segment must precede last segment")
	ErrKeySegNotFound   = errors.New("segment not found by key")
	ErrDataUnparsable = errors.New("data cannot be parsed")
)