You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: be_element_of_matcher.go
    path of file: ./repos/kubernetes/vendor/github.com/onsi/gomega/matchers
    
    the code of the file until where you have to start completion: // untested sections: 1

package matchers

import (
	"fmt"
	"reflect"

	"github.com/onsi/gomega/format"
)

type BeElementOfMatcher struct {
	Elements []interface{}
}

func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err error) {
	if reflect.TypeOf(actual) == nil {
		return false, fmt.Errorf("BeElement matcher expects actual to be typed")
	}

    
func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err error) {
	if reflect.TypeOf(actual) == nil {
		return false, fmt.Errorf("BeElement matcher expects actual to be typed")
	}

	var lastError error
	for _, m := range flatten(matcher.Elements) {
		matcher := &EqualMatcher{Expected: m}
		success, err := matcher.Match(actual)
		if err != nil {
			lastError = err
			continue
		}
		if success {
			return true, nil
		}
	}

	return false, lastError
}