Bind: takes a pointer for the second argument (#152)
This commit is contained in:
12
wire.go
12
wire.go
@@ -93,9 +93,9 @@ func Build(...interface{}) string {
|
||||
// A Binding maps an interface to a concrete type.
|
||||
type Binding struct{}
|
||||
|
||||
// Bind declares that a concrete type should be used to satisfy a
|
||||
// dependency on the type of iface, which must be a pointer to an
|
||||
// interface type.
|
||||
// Bind declares that a concrete type should be used to satisfy a dependency on
|
||||
// the type of iface. iface must be a pointer to an interface type, to must be a
|
||||
// pointer to a concrete type.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
@@ -108,12 +108,16 @@ type Binding struct{}
|
||||
// func (MyFoo) Foo() {}
|
||||
//
|
||||
// var MySet = wire.NewSet(
|
||||
// MyFoo{},
|
||||
// wire.Struct(new(MyFoo))
|
||||
// wire.Bind(new(Fooer), new(MyFoo)))
|
||||
func Bind(iface, to interface{}) Binding {
|
||||
return Binding{}
|
||||
}
|
||||
|
||||
// bindToUsePointer is detected by the wire tool to indicate that Bind's second argument should take a pointer.
|
||||
// See https://github.com/google/wire/issues/120 for details.
|
||||
const bindToUsePointer = true
|
||||
|
||||
// A ProvidedValue is an expression that is copied to the generated injector.
|
||||
type ProvidedValue struct{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user