upgrade

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package upgrade solves an issue that results from the intersections of two common patterns in luce. There are many interface wrappers (or decorators). These wrap an interface to add functionality. The other pattern is upgradeable interfaces. This is were an object can provide additional functionality and hinting by fulfilling optional interfaces.

For example, take the following

  • bytes.Buffer: fulfills io.Writer and io.StringWriter
  • WriterWrapper: wraps an io.Writer, does not fulfill io.StringWriter
  • func Foo(w io.Writer): tries to cast w to StringWriter, uses fallback code if it can't

If a Buffer is passed into Foo, the StringWriter cast will work, but if a WriterWrapper around a Buffer is passed in, it will fail.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func To

func To[T any](wrapper any) (to T, ok bool)

TODO: need test to confirm matching at multiple levels

Types

type Wrapper

type Wrapper interface {
	Wrapped() any
}

Jump to

Keyboard shortcuts

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