func NewBySubSpan(path, key string, i, j int) *Parth {
	s, err := SubSpan(path, key, i, j)
	return &Parth{s, err}
}
NewBySubSpan constructs a pointer to an instance of Parth after
preprocessing the provided path with SubSpan.
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")
)
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
}
func Sequent(path, key string, v interface{}) error {
	return SubSeg(path, key, 0, v)
}
func Span(path string, i, j int) (string, error) {
	var f, l int
	var ok bool
	if i < 0 {
		f, ok = segStartIndexFromEnd(path, i)
	} else {
		f, ok = segStartIndexFromStart(path, i)
	}
	if !ok {
		return "", ErrFirstSegNotFound
	}
	if j > 0 {
		l, ok = segEndIndexFromStart(path, j)
	} else {
		l, ok = segEndIndexFromEnd(path, j)
	}
	if !ok {
		return "", ErrLastSegNotFound
	}
	if f == l {
		return "", nil
	}
	if f > l {
		return "", ErrSegOrderReversed
	}
	return path[f:l], nil
}
func SubSeg(path, key string, i int, v interface{}) error {  
	var err error
	switch v := v.(type) {
	case *bool:
		*v, err = subSegToBool(path, key, i)
	case *float32:
		var f float64
		f, err = subSegToFloatN(path, key, i, 32)
		*v = float32(f)
	case *float64:
		*v, err = subSegToFloatN(path, key, i, 64)
	case *int:
		var n int64
		n, err = subSegToIntN(path, key, i, 0)
		*v = int(n)
	case *int16:
		var n int64
		n, err = subSegToIntN(path, key, i, 16)
		*v = int16(n)
	case *int32:
		var n int64
		n, err = subSegToIntN(path, key, i, 32)
		*v = int32(n)
	case *int64:
		*v, err = subSegToIntN(path, key, i, 64)
	case *int8:
		var n int64
		n, err = subSegToIntN(path, key, i, 8)
		*v = int8(n)
	case *string:
		*v, err = subSegToString(path, key, i)
	case *uint:
		var n uint64
		n, err = subSegToUintN(path, key, i, 0)
		*v = uint(n)
	case *uint16:
		var n uint64
		n, err = subSegToUintN(path, key, i, 16)
		*v = uint16(n)
	case *uint32:
		var n uint64
		n, err = subSegToUintN(path, key, i, 32)
		*v = uint32(n)
	case *uint64:
		*v, err = subSegToUintN(path, key, i, 64)
	case *uint8:
		var n uint64
		n, err = subSegToUintN(path, key, i, 8)
		*v = uint8(n)
	case Unmarshaler:
		var s string
		s, err = subSegToString(path, key, i)
		if err == nil {
			err = v.UnmarshalSegment(s)
		}
	default:
		err = ErrUnknownType
	}
	return err
}
func SubSpan(path, key string, i, j int) (string, error) {
	si, ok := segIndexByKey(path, key)
	if !ok {
		return "", ErrKeySegNotFound
	}
	if i >= 0 {
		i++
	}
	if j > 0 {
		j++
	}
	s, err := Span(path[si:], i, j)
	if err != nil {
		return "", err
	}
	return s, nil
}
type Parth struct {
	path string
	err  error
}
func New(path string) *Parth {
	return &Parth{path: path}
}
func NewBySpan(path string, i, j int) *Parth {
	s, err := Span(path, i, j)
	return &Parth{s, err}
}