c

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package c provides common types and functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IterFor added in v0.0.10

type IterFor[T any, I Iterator[T]] interface {
	// Start is used with for loop construct.
	// Returns the iterator itself, the first element, ok == false if the iteration must be completed, and an error.
	//
	// 	var i IterFor = ...
	//	for i, val, ok, err := i.Start(); ok || err != nil; val, ok, err = i.Next() {
	//		if err != nil {
	//			return err
	//		}
	//	}
	Start() (iterator I, val T, ok bool, err error)
}

IterFor extends an iterator type by a 'Start' function implementation

type Iterator

type Iterator[T any] interface {
	// Next returns the next element.
	// The ok result indicates whether the element was returned by the iterator.
	// If ok == false, then the iteration must be completed.
	Next() (out T, ok bool, err error)

	c.ForLoop[T]
}

Iterator provides iterate over elements of a source, where an iteration can be interrupted by an error

Jump to

Keyboard shortcuts

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