Skip to content

Commit

Permalink
move Unmarshaler interface to unastable
Browse files Browse the repository at this point in the history
  • Loading branch information
rszyma committed Mar 14, 2024
1 parent d7cb2b7 commit de8d3e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 1 addition & 7 deletions unmarshaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ import (
"github.com/pelletier/go-toml/v2/unstable"
)

// The Unmarshaler interface may be implemented by types to customize their
// behavior when being unmarshaled from a TOML document.
type Unmarshaler interface {
UnmarshalTOML(value *unstable.Node) error
}

// Unmarshal deserializes a TOML document into a Go value.
//
// It is a shortcut for Decoder.Decode() with the default options.
Expand Down Expand Up @@ -673,7 +667,7 @@ func (d *decoder) handleValue(value *unstable.Node, v reflect.Value) error {

if d.unmarshalerInterface {
if v.CanAddr() && v.Addr().CanInterface() {
if outi, ok := v.Addr().Interface().(Unmarshaler); ok {
if outi, ok := v.Addr().Interface().(unstable.Unmarshaler); ok {
return outi.UnmarshalTOML(value)
}
}
Expand Down
7 changes: 7 additions & 0 deletions unstable/unmarshaler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package unstable

// The Unmarshaler interface may be implemented by types to customize their
// behavior when being unmarshaled from a TOML document.
type Unmarshaler interface {
UnmarshalTOML(value *Node) error
}

0 comments on commit de8d3e9

Please sign in to comment.