illegal

package module
v0.0.0-...-112e5c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2014 License: BSD-3-Clause Imports: 1 Imported by: 0

README

illegal Build Status

Support for operations which are disallowed by the Go compiler.

###Features

  • Comparison of two function pointers for equality
  • Element-by-element conversion of slices ([]T to []U if T can be converted to U)
  • Traditional functional, generic functions such as Map and Filter

See the documentation.

Documentation

Overview

Package illegal provides runtime support for operations which are disallowed by the compiler.

Index

Constants

This section is empty.

Variables

View Source
var (
	InterfaceType reflect.Type
)

Convenience reflect.Type values

Functions

func ConvertSlice

func ConvertSlice(slc, example interface{}) interface{}

Convert each element in slc to example's underlying type, and return the conversions in a new slice.

ConvertSlice panics if slc is not a slice value, or if the conversion is illegal.

If ConvertSlice returns without panicking, the return value's underlying value is guaranteed to be a slice, and the element type is guaranteed to be of the same type as example.

func ConvertSliceType

func ConvertSliceType(slc interface{}, typ reflect.Type) interface{}

Convert each element in slc to the given type, and return the conversions in a new slice.

ConvertSlice panics if slc is not a slice value, or if the conversion is illegal.

If ConvertSliceType returns without panicking, the return value's underlying value is guaranteed to be a slice, and the element type is guaranteed to be of the same type as typ.

func FuncEqual

func FuncEqual(f1, f2 interface{}) bool

FuncEqual figures out if two function pointers reference the same function. For two closures created from the same original function, it will say that they are equal.

FuncEqual also works on methods. Note that if two interface variables of the same interface type but of two separate concrete types are used to get a function pointer, that pointer will point at the interface methods, not the methods associated with the concrete types, so they will register as equal.

FuncEqual panics if either argument is not a function.

Types

This section is empty.

Directories

Path Synopsis
Package generics implements common generic functions.
Package generics implements common generic functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL