Skip to content

[Bug]: Any implementation is incorrect #2

@benjivesterby

Description

@benjivesterby

This doesn't compile. It should work.

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"strings"
)

func main() {

	readers := As[io.Reader](
		strings.NewReader(""),
		bufio.NewReader(strings.NewReader("")),
		bytes.NewBuffer([]byte("")),
	)

	fmt.Printf("%T\n", readers)

	buffers1 := []*bytes.Buffer{
		bytes.NewBuffer([]byte("")),
		bytes.NewBuffer([]byte("")),
		bytes.NewBuffer([]byte("")),
		bytes.NewBuffer([]byte("")),
		bytes.NewBuffer([]byte("")),
	}

	// breaders := As[io.Reader](buffers1...)

	stringrs := []*strings.Reader{
		strings.NewReader(""),
	}

	strs := As[io.Reader](stringrs...)

	var all []io.Reader
	// all = append(all, buffers1...)

	all = Merge[io.Reader](breaders...)
}

func As[T any](in ...T) []T {
	return in
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions