gost

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 9 Imported by: 0

README

gost

GitHub license

Experience the true taste of Rust in Go

document

Install

go get github.com/myyrakle/gost@v0.7.0

Example

package main

import (
	"math"

	gost "github.com/myyrakle/gost"
)

func CheckedAdd(a, b gost.ISize) gost.Option[gost.ISize] {
	max := gost.ISize(math.MaxInt)
	if (b > 0 && a > max-b) || (b < 0 && a < max-b) {
		return gost.None[gost.ISize]()
	}

	return gost.Some(a + b)
}

func main() {
	a := gost.ISize(1)
	b := gost.ISize(2)
	result := CheckedAdd(a, b)

	if result.IsSome() {
		gost.Println("result: {}", result.Unwrap())
	} else {
		gost.Println("result: overflow")
	}

	a = gost.ISize(math.MaxInt)
	b = gost.ISize(1)
	result = CheckedAdd(a, b)

	if result.IsSome() {
		gost.Println("result: {}", result.Unwrap())
	} else {
		gost.Println("result: overflow")
	}

	vector := gost.Vec[gost.ISize]{}
	vector.Push(gost.ISize(3))
	vector.Push(gost.ISize(1))
	vector.Push(gost.ISize(2))
	vector.Push(gost.ISize(4))
	vector.Sort()
	gost.Println("sorted Vec: {}", vector)

	newVec := vector.IntoIter().Map(func(x gost.ISize) gost.ISize { return x * 2 }).CollectToVec()
	gost.Println("mapped Vec: {}", newVec)

	newVec.Push(gost.ISize(7))
	foo := newVec.IntoIter().Fold(gost.ISize(0), func(a, b gost.ISize) gost.ISize { return a + b })
	gost.Println("fold value: {}", foo)

	hashMap := gost.HashMapNew[gost.String, gost.ISize]()
	hashMap.Insert(gost.String("foo"), gost.ISize(1))
	hashMap.Insert(gost.String("bar"), gost.ISize(2))
	hashMap.Insert(gost.String("baz"), gost.ISize(3))

	gost.Println("hashMap: {}", hashMap)

	linkedList := gost.LinkedListNew[gost.ISize]()
	linkedList.PushBack(gost.ISize(1))
	linkedList.PushFront(gost.ISize(2))
	linkedList.PushBack(gost.ISize(3))
	linkedList2 := gost.LinkedListNew[gost.ISize]()
	linkedList2.PushBack(gost.ISize(4))
	linkedList2.PushFront(gost.ISize(5))
	linkedList.Append(&linkedList2)

	gost.Println("linkedList: {}", linkedList)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(format String, params ...any)

func Println

func Println(format String, params ...any)

Types

type Add

type Add[T any] interface {
	Add(rhs T) T
}

Add is a trait for types that support addition.

type AddAssign

type AddAssign[T any] interface {
	AddAssign(rhs T)
}

The addition assignment operator +=.

type Any

type Any interface{}

type BTreeMap added in v0.7.0

type BTreeMap[K Ord[K], V any] struct {
	// contains filtered or unexported fields
}

func BTreeMapNew added in v0.7.0

func BTreeMapNew[K Ord[K], V any]() BTreeMap[K, V]

Creates an empty BTreeMap.

func (*BTreeMap[K, V]) Clear added in v0.7.0

func (self *BTreeMap[K, V]) Clear()

Clears the map, removing all elements.

func (*BTreeMap[K, V]) ContainsKey added in v0.7.0

func (self *BTreeMap[K, V]) ContainsKey(key K) Bool

Returns true if the map contains a value for the specified key. The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

func (BTreeMap[K, V]) Debug added in v0.7.0

func (self BTreeMap[K, V]) Debug() String

impl Debug for HashMap

func (BTreeMap[K, V]) Display added in v0.7.0

func (self BTreeMap[K, V]) Display() String

impl Display for BTreeMap

func (*BTreeMap[K, V]) Get added in v0.7.0

func (self *BTreeMap[K, V]) Get(key K) Option[V]

Returns value corresponding to the key.

func (*BTreeMap[K, V]) Insert added in v0.7.0

func (self *BTreeMap[K, V]) Insert(key K, value V) Option[V]

Inserts a key-value pair into the map. If the map did not have this key present, None is returned. If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the module-level documentation for more.

func (BTreeMap[K, V]) IntoIter added in v0.7.0

func (self BTreeMap[K, V]) IntoIter() Iterator[Pair[K, V]]

into_iter

func (*BTreeMap[K, V]) IsEmpty added in v0.7.0

func (self *BTreeMap[K, V]) IsEmpty() Bool

Returns true if the map contains no elements.

func (BTreeMap[K, V]) Keys added in v0.7.0

func (self BTreeMap[K, V]) Keys() Iterator[K]

An iterator visiting all keys in arbitrary order. The iterator element type is K.

func (*BTreeMap[K, V]) Len added in v0.7.0

func (self *BTreeMap[K, V]) Len() USize

Returns the number of elements in the map.

func (*BTreeMap[K, V]) Remove added in v0.7.0

func (self *BTreeMap[K, V]) Remove(key K) Option[V]

Removes a key from the map, returning the value at the key if the key was previously in the map. The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.

func (BTreeMap[K, V]) Values added in v0.7.0

func (self BTreeMap[K, V]) Values() Iterator[V]

An iterator visiting all values in arbitrary order. The iterator element type is V.

type BTreeMapIter added in v0.7.0

type BTreeMapIter[K Ord[K], V any] struct {
	// contains filtered or unexported fields
}

func (BTreeMapIter[K, V]) CollectToLinkedList added in v0.7.0

func (self BTreeMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]

Collect to LinkedList

func (BTreeMapIter[K, V]) CollectToVec added in v0.7.0

func (self BTreeMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]

func (*BTreeMapIter[K, V]) Filter added in v0.7.0

func (self *BTreeMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]

filter

func (*BTreeMapIter[K, V]) Fold added in v0.7.0

func (self *BTreeMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]

fold

func (*BTreeMapIter[K, V]) Map added in v0.7.0

func (self *BTreeMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]

map

func (*BTreeMapIter[K, V]) Next added in v0.7.0

func (self *BTreeMapIter[K, V]) Next() Option[Pair[K, V]]

next

func (BTreeMapIter[K, V]) Rev added in v0.7.0

func (self BTreeMapIter[K, V]) Rev() Iterator[Pair[K, V]]

rev

type BTreeMapKeys added in v0.7.0

type BTreeMapKeys[K any] struct {
	// contains filtered or unexported fields
}

func (BTreeMapKeys[K]) CollectToLinkedList added in v0.7.0

func (self BTreeMapKeys[K]) CollectToLinkedList() LinkedList[K]

Collect to LinkedList

func (BTreeMapKeys[K]) CollectToVec added in v0.7.0

func (self BTreeMapKeys[K]) CollectToVec() Vec[K]

Collect to Vec

func (*BTreeMapKeys[K]) Filter added in v0.7.0

func (self *BTreeMapKeys[K]) Filter(f func(K) Bool) Iterator[K]

filter

func (*BTreeMapKeys[K]) Fold added in v0.7.0

func (self *BTreeMapKeys[K]) Fold(init K, f func(K, K) K) K

fold

func (*BTreeMapKeys[K]) Map added in v0.7.0

func (self *BTreeMapKeys[K]) Map(f func(K) K) Iterator[K]

map

func (*BTreeMapKeys[K]) Next added in v0.7.0

func (self *BTreeMapKeys[K]) Next() Option[K]

next

func (BTreeMapKeys[K]) Rev added in v0.7.0

func (self BTreeMapKeys[K]) Rev() Iterator[K]

rev

type BTreeMapValues added in v0.7.0

type BTreeMapValues[V any] struct {
	// contains filtered or unexported fields
}

func (BTreeMapValues[V]) CollectToLinkedList added in v0.7.0

func (self BTreeMapValues[V]) CollectToLinkedList() LinkedList[V]

Collect to LinkedList

func (BTreeMapValues[V]) CollectToVec added in v0.7.0

func (self BTreeMapValues[V]) CollectToVec() Vec[V]

Collect to Vec

func (*BTreeMapValues[V]) Filter added in v0.7.0

func (self *BTreeMapValues[V]) Filter(f func(V) Bool) Iterator[V]

filter

func (*BTreeMapValues[V]) Fold added in v0.7.0

func (self *BTreeMapValues[V]) Fold(init V, f func(V, V) V) V

fold

func (*BTreeMapValues[V]) Map added in v0.7.0

func (self *BTreeMapValues[V]) Map(f func(V) V) Iterator[V]

map

func (*BTreeMapValues[V]) Next added in v0.7.0

func (self *BTreeMapValues[V]) Next() Option[V]

next

func (BTreeMapValues[V]) Rev added in v0.7.0

func (self BTreeMapValues[V]) Rev() Iterator[V]

rev

type BTreeNode added in v0.7.0

type BTreeNode[K Ord[K], V any] struct {
	// contains filtered or unexported fields
}

type BTreeSet added in v0.7.0

type BTreeSet[K Ord[K]] struct {
	// contains filtered or unexported fields
}

func BTreeSetNew added in v0.7.0

func BTreeSetNew[K Ord[K]]() BTreeSet[K]

Creates an empty BTreeSet.

func (*BTreeSet[K]) Clear added in v0.7.0

func (self *BTreeSet[K]) Clear()

Clears the set, removing all elements.

func (*BTreeSet[K]) Contains added in v0.7.0

func (self *BTreeSet[K]) Contains(key K) Bool

Returns true if the set contains an element equal to the value. The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.

func (BTreeSet[K]) Debug added in v0.7.0

func (self BTreeSet[K]) Debug() String

impl Debug for BTreeSet

func (BTreeSet[K]) Display added in v0.7.0

func (self BTreeSet[K]) Display() String

impl Display for BTreeSet

func (*BTreeSet[K]) Insert added in v0.7.0

func (self *BTreeSet[K]) Insert(key K) Bool

Adds a value to the set. Returns whether the value was newly inserted. That is: If the set did not previously contain an equal value, true is returned. If the set already contained an equal value, false is returned, and the entry is not updated.

func (*BTreeSet[K]) IntoIter added in v0.7.0

func (self *BTreeSet[K]) IntoIter() Iterator[K]

into_iter

func (*BTreeSet[K]) IsEmpty added in v0.7.0

func (self *BTreeSet[K]) IsEmpty() Bool

Returns true if the set contains no elements.

func (*BTreeSet[K]) Len added in v0.7.0

func (self *BTreeSet[K]) Len() USize

Returns the number of elements in the set.

func (*BTreeSet[K]) Remove added in v0.7.0

func (self *BTreeSet[K]) Remove(key K) Bool

If the set contains an element equal to the value, removes it from the set and drops it. Returns whether such an element was present. The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.

type BTreeSetIter added in v0.7.0

type BTreeSetIter[K Ord[K]] struct {
	// contains filtered or unexported fields
}

func (BTreeSetIter[K]) CollectToLinkedList added in v0.7.0

func (self BTreeSetIter[K]) CollectToLinkedList() LinkedList[K]

Collect to LinkedList

func (BTreeSetIter[K]) CollectToVec added in v0.7.0

func (self BTreeSetIter[K]) CollectToVec() Vec[K]

Collect to Vec

func (BTreeSetIter[K]) Filter added in v0.7.0

func (self BTreeSetIter[K]) Filter(f func(K) Bool) Iterator[K]

filter

func (BTreeSetIter[K]) Fold added in v0.7.0

func (self BTreeSetIter[K]) Fold(init K, f func(K, K) K) K

fold

func (BTreeSetIter[K]) Map added in v0.7.0

func (self BTreeSetIter[K]) Map(f func(K) K) Iterator[K]

map

func (*BTreeSetIter[K]) Next added in v0.7.0

func (self *BTreeSetIter[K]) Next() Option[K]

next

func (BTreeSetIter[K]) Rev added in v0.7.0

func (self BTreeSetIter[K]) Rev() Iterator[K]

rev

type Bool

type Bool bool

func (Bool) Clone

func (self Bool) Clone() Bool

func (Bool) Cmp

func (self Bool) Cmp(rhs Bool) Ordering

func (Bool) Debug

func (self Bool) Debug() String

func (Bool) Display

func (self Bool) Display() String

func (Bool) Eq

func (self Bool) Eq(rhs Bool) Bool

func (Bool) ToString

func (self Bool) ToString() String

type Byte

type Byte byte

func (Byte) Add added in v0.6.0

func (self Byte) Add(rhs Byte) Byte

func (*Byte) AddAssign added in v0.6.0

func (self *Byte) AddAssign(rhs Byte)

func (Byte) Clone

func (self Byte) Clone() Byte

func (Byte) Cmp

func (self Byte) Cmp(rhs Byte) Ordering

func (Byte) Debug

func (self Byte) Debug() String

func (Byte) Display

func (self Byte) Display() String

func (Byte) Div added in v0.6.0

func (self Byte) Div(rhs Byte) Byte

func (*Byte) DivAssign added in v0.6.0

func (self *Byte) DivAssign(rhs Byte)

func (Byte) Eq

func (self Byte) Eq(rhs Byte) Bool

func (Byte) Mul added in v0.6.0

func (self Byte) Mul(rhs Byte) Byte

func (*Byte) MulAssign added in v0.6.0

func (self *Byte) MulAssign(rhs Byte)

func (Byte) Sub added in v0.6.0

func (self Byte) Sub(rhs Byte) Byte

func (*Byte) SubAssign added in v0.6.0

func (self *Byte) SubAssign(rhs Byte)

func (Byte) ToString

func (self Byte) ToString() String

type Char added in v0.6.0

type Char rune

func (Char) Add added in v0.6.0

func (self Char) Add(rhs Char) Char

func (*Char) AddAssign added in v0.6.0

func (self *Char) AddAssign(rhs Char)

func (Char) Clone added in v0.6.0

func (self Char) Clone() Char

func (Char) Cmp added in v0.6.0

func (self Char) Cmp(rhs Char) Ordering

func (Char) Debug added in v0.6.0

func (self Char) Debug() String

func (Char) Display added in v0.6.0

func (self Char) Display() String

func (Char) Div added in v0.6.0

func (self Char) Div(rhs Char) Char

func (*Char) DivAssign added in v0.6.0

func (self *Char) DivAssign(rhs Char)

func (Char) Eq added in v0.6.0

func (self Char) Eq(rhs Char) Bool

func (Char) Mul added in v0.6.0

func (self Char) Mul(rhs Char) Char

func (*Char) MulAssign added in v0.6.0

func (self *Char) MulAssign(rhs Char)

func (Char) Sub added in v0.6.0

func (self Char) Sub(rhs Char) Char

func (*Char) SubAssign added in v0.6.0

func (self *Char) SubAssign(rhs Char)

func (Char) ToString added in v0.6.0

func (self Char) ToString() String

type Clone

type Clone[T any] interface {
	Clone() T
}

type Complex128

type Complex128 complex128

func (Complex128) Add added in v0.6.0

func (self Complex128) Add(rhs Complex128) Complex128

func (*Complex128) AddAssign added in v0.6.0

func (self *Complex128) AddAssign(rhs Complex128)

func (Complex128) Clone

func (self Complex128) Clone() Complex128

func (Complex128) Debug

func (self Complex128) Debug() String

func (Complex128) Display

func (self Complex128) Display() String

func (Complex128) Div added in v0.6.0

func (self Complex128) Div(rhs Complex128) Complex128

func (*Complex128) DivAssign added in v0.6.0

func (self *Complex128) DivAssign(rhs Complex128)

func (Complex128) Mul added in v0.6.0

func (self Complex128) Mul(rhs Complex128) Complex128

func (*Complex128) MulAssign added in v0.6.0

func (self *Complex128) MulAssign(rhs Complex128)

func (Complex128) Sub added in v0.6.0

func (self Complex128) Sub(rhs Complex128) Complex128

func (*Complex128) SubAssign added in v0.6.0

func (self *Complex128) SubAssign(rhs Complex128)

func (Complex128) ToString

func (self Complex128) ToString() String

type Complex64

type Complex64 complex64

func (Complex64) Add added in v0.6.0

func (self Complex64) Add(rhs Complex64) Complex64

func (*Complex64) AddAssign added in v0.6.0

func (self *Complex64) AddAssign(rhs Complex64)

func (Complex64) Clone

func (self Complex64) Clone() Complex64

func (Complex64) Debug

func (self Complex64) Debug() String

func (Complex64) Display

func (self Complex64) Display() String

func (Complex64) Div added in v0.6.0

func (self Complex64) Div(rhs Complex64) Complex64

func (*Complex64) DivAssign added in v0.6.0

func (self *Complex64) DivAssign(rhs Complex64)

func (Complex64) Mul added in v0.6.0

func (self Complex64) Mul(rhs Complex64) Complex64

func (*Complex64) MulAssign added in v0.6.0

func (self *Complex64) MulAssign(rhs Complex64)

func (Complex64) Sub added in v0.6.0

func (self Complex64) Sub(rhs Complex64) Complex64

func (*Complex64) SubAssign added in v0.6.0

func (self *Complex64) SubAssign(rhs Complex64)

func (Complex64) ToString

func (self Complex64) ToString() String

type Debug

type Debug[T any] interface {
	Debug() string
}

type Default

type Default[T any] interface {
	Default() T
}

A trait for giving a type a useful default value.

type DirEntry

type DirEntry struct {
	FileName String
	Path     String
	FileType FileType
}

type Display

type Display[T any] interface {
	Display() String
}

type Div

type Div[T any] interface {
	Div(rhs T) T
}

Div is a trait for types that support division.

type DivAssign

type DivAssign[T any] interface {
	DivAssign(rhs T)
}

The division assignment operator /=.

type Eq

type Eq[T any] interface {
	Eq(rhs T) Bool
}

type Error

type Error error

type F32 added in v0.6.0

type F32 float32

func (F32) Add added in v0.6.0

func (self F32) Add(rhs F32) F32

func (*F32) AddAssign added in v0.6.0

func (self *F32) AddAssign(rhs F32)

func (F32) Clone added in v0.6.0

func (self F32) Clone() F32

func (F32) Cmp added in v0.6.0

func (self F32) Cmp(rhs F32) Ordering

func (F32) Debug added in v0.6.0

func (self F32) Debug() String

func (F32) Display added in v0.6.0

func (self F32) Display() String

func (F32) Div added in v0.6.0

func (self F32) Div(rhs F32) F32

func (*F32) DivAssign added in v0.6.0

func (self *F32) DivAssign(rhs F32)

func (F32) Eq added in v0.6.0

func (self F32) Eq(rhs F32) Bool

func (F32) Mul added in v0.6.0

func (self F32) Mul(rhs F32) F32

func (*F32) MulAssign added in v0.6.0

func (self *F32) MulAssign(rhs F32)

func (F32) Sub added in v0.6.0

func (self F32) Sub(rhs F32) F32

func (*F32) SubAssign added in v0.6.0

func (self *F32) SubAssign(rhs F32)

func (F32) ToString added in v0.6.0

func (self F32) ToString() String

type F64 added in v0.6.0

type F64 float64

func (F64) Add added in v0.6.0

func (self F64) Add(rhs F64) F64

func (*F64) AddAssign added in v0.6.0

func (self *F64) AddAssign(rhs F64)

func (F64) Clone added in v0.6.0

func (self F64) Clone() F64

func (F64) Cmp added in v0.6.0

func (self F64) Cmp(rhs F64) Ordering

func (F64) Debug added in v0.6.0

func (self F64) Debug() String

func (F64) Display added in v0.6.0

func (self F64) Display() String

func (F64) Div added in v0.6.0

func (self F64) Div(rhs F64) F64

func (*F64) DivAssign added in v0.6.0

func (self *F64) DivAssign(rhs F64)

func (F64) Eq added in v0.6.0

func (self F64) Eq(rhs F64) Bool

func (F64) Mul added in v0.6.0

func (self F64) Mul(rhs F64) F64

func (*F64) MulAssign added in v0.6.0

func (self *F64) MulAssign(rhs F64)

func (F64) Sub added in v0.6.0

func (self F64) Sub(rhs F64) F64

func (*F64) SubAssign added in v0.6.0

func (self *F64) SubAssign(rhs F64)

func (F64) ToString added in v0.6.0

func (self F64) ToString() String

type FileType

type FileType struct {
	// contains filtered or unexported fields
}

func (FileType) IsDir

func (self FileType) IsDir() bool

func (FileType) IsFile

func (self FileType) IsFile() bool
func (self FileType) IsSymlink() bool

type HashMap

type HashMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func HashMapNew

func HashMapNew[K comparable, V any]() HashMap[K, V]

Creates an empty HashMap.

func HashMapWithCapacity

func HashMapWithCapacity[K comparable, V any](capacity USize) HashMap[K, V]

Creates an empty HashMap with at least the specified capacity.

func (HashMap[K, V]) AsMap

func (self HashMap[K, V]) AsMap() map[K]V

As Raw Map

func (*HashMap[K, V]) Clear

func (self *HashMap[K, V]) Clear()

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

func (HashMap[K, V]) ContainsKey

func (self HashMap[K, V]) ContainsKey(key K) Bool

Returns true if the map contains a value for the specified key.

func (HashMap[K, V]) Debug

func (self HashMap[K, V]) Debug() String

impl Debug for HashMap

func (HashMap[K, V]) Display

func (self HashMap[K, V]) Display() String

impl Display for HashMap

func (HashMap[K, V]) Get

func (self HashMap[K, V]) Get(key K) Option[V]

Returns value corresponding to the key.

func (*HashMap[K, V]) Insert

func (self *HashMap[K, V]) Insert(key K, value V) Option[V]

Inserts a key-value pair into the map. If the map did not have this key present, None is returned.

func (HashMap[K, V]) IntoIter

func (self HashMap[K, V]) IntoIter() Iterator[Pair[K, V]]

into_iter

func (HashMap[K, V]) IsEmpty

func (self HashMap[K, V]) IsEmpty() Bool

Returns true if the map contains no elements.

func (HashMap[K, V]) Keys

func (self HashMap[K, V]) Keys() Iterator[K]

An iterator visiting all keys in arbitrary order. The iterator element type is K.

func (HashMap[K, V]) Len

func (self HashMap[K, V]) Len() USize

Returns the number of elements in the map.

func (*HashMap[K, V]) Remove

func (self *HashMap[K, V]) Remove(key K) Option[V]

Removes a key from the map, returning the value at the key if the key was previously in the map.

func (HashMap[K, V]) Values

func (self HashMap[K, V]) Values() Iterator[V]

An iterator visiting all values in arbitrary order. The iterator element type is V.

type HashMapIter

type HashMapIter[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func (HashMapIter[K, V]) CollectToLinkedList added in v0.6.0

func (self HashMapIter[K, V]) CollectToLinkedList() LinkedList[Pair[K, V]]

Collect to LinkedList

func (HashMapIter[K, V]) CollectToVec

func (self HashMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]

func (HashMapIter[K, V]) Filter

func (self HashMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]

filter

func (HashMapIter[K, V]) Fold

func (self HashMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]

fold

func (HashMapIter[K, V]) Map

func (self HashMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]

map

func (*HashMapIter[K, V]) Next

func (self *HashMapIter[K, V]) Next() Option[Pair[K, V]]

next

func (HashMapIter[K, V]) Rev

func (self HashMapIter[K, V]) Rev() Iterator[Pair[K, V]]

rev

type HashMapKeys

type HashMapKeys[K any] struct {
	// contains filtered or unexported fields
}

func (HashMapKeys[K]) CollectToLinkedList added in v0.6.0

func (self HashMapKeys[K]) CollectToLinkedList() LinkedList[K]

Collect to LinkedList

func (HashMapKeys[K]) CollectToVec

func (self HashMapKeys[K]) CollectToVec() Vec[K]

Collect to Vec

func (HashMapKeys[K]) Filter

func (self HashMapKeys[K]) Filter(f func(K) Bool) Iterator[K]

filter

func (HashMapKeys[K]) Fold

func (self HashMapKeys[K]) Fold(init K, f func(K, K) K) K

fold

func (HashMapKeys[K]) Map

func (self HashMapKeys[K]) Map(f func(K) K) Iterator[K]

map

func (*HashMapKeys[K]) Next

func (self *HashMapKeys[K]) Next() Option[K]

next

func (HashMapKeys[K]) Rev

func (self HashMapKeys[K]) Rev() Iterator[K]

rev

type HashMapValues

type HashMapValues[V any] struct {
	// contains filtered or unexported fields
}

func (HashMapValues[V]) CollectToLinkedList added in v0.6.0

func (self HashMapValues[V]) CollectToLinkedList() LinkedList[V]

Collect to LinkedList

func (HashMapValues[V]) CollectToVec

func (self HashMapValues[V]) CollectToVec() Vec[V]

Collect to Vec

func (HashMapValues[V]) Filter

func (self HashMapValues[V]) Filter(f func(V) Bool) Iterator[V]

filter

func (HashMapValues[V]) Fold

func (self HashMapValues[V]) Fold(init V, f func(V, V) V) V

fold

func (HashMapValues[V]) Map

func (self HashMapValues[V]) Map(f func(V) V) Iterator[V]

map

func (*HashMapValues[V]) Next

func (self *HashMapValues[V]) Next() Option[V]

next

func (HashMapValues[V]) Rev

func (self HashMapValues[V]) Rev() Iterator[V]

rev

type HashSet added in v0.7.0

type HashSet[K comparable] struct {
	// contains filtered or unexported fields
}

func HashSetFromSlice added in v0.7.0

func HashSetFromSlice[K comparable](slice []K) HashSet[K]

From Slice

func HashSetNew added in v0.7.0

func HashSetNew[K comparable]() HashSet[K]

Creates an empty HashSet.

func HashSetWithCapacity added in v0.7.0

func HashSetWithCapacity[K comparable](capacity USize) HashSet[K]

Creates an empty HashSet with at least the specified capacity.

func (HashSet[K]) AsSlice added in v0.7.0

func (self HashSet[K]) AsSlice() []K

As Slice

func (*HashSet[K]) Clear added in v0.7.0

func (self *HashSet[K]) Clear()

Clears the set, removing all values.

func (HashSet[K]) Contains added in v0.7.0

func (self HashSet[K]) Contains(value K) Bool

Returns true if the set contains a value. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.

func (HashSet[K]) Debug added in v0.7.0

func (self HashSet[K]) Debug() String

impl Debug for HashSet

func (HashSet[K]) Display added in v0.7.0

func (self HashSet[K]) Display() String

impl Display for HashSet

func (HashSet[K]) Get added in v0.7.0

func (self HashSet[K]) Get(value K) Option[K]

Returns a reference to the value in the set, if any, that is equal to the given value. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.

func (*HashSet[K]) Insert added in v0.7.0

func (self *HashSet[K]) Insert(value K) Bool

Adds a value to the set. Returns whether the value was newly inserted. That is: If the set did not previously contain this value, true is returned. If the set already contained this value, false is returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.

func (HashSet[K]) IntoIter added in v0.7.0

func (self HashSet[K]) IntoIter() Iterator[K]

into_iter

func (HashSet[K]) IsEmpty added in v0.7.0

func (self HashSet[K]) IsEmpty() Bool

Returns true if the set contains no elements.

func (HashSet[K]) Len added in v0.7.0

func (self HashSet[K]) Len() USize

Returns the number of elements in the set.

func (*HashSet[K]) Remove added in v0.7.0

func (self *HashSet[K]) Remove(value K) Bool

Removes a value from the set. Returns whether the value was present in the set. The value may be any borrowed form of the set’s value type, but Hash and Eq on the borrowed form must match those for the value type.

type HashSetIter added in v0.7.0

type HashSetIter[K comparable] struct {
	// contains filtered or unexported fields
}

func (HashSetIter[K]) CollectToLinkedList added in v0.7.0

func (self HashSetIter[K]) CollectToLinkedList() LinkedList[K]

Collect to LinkedList

func (HashSetIter[K]) CollectToVec added in v0.7.0

func (self HashSetIter[K]) CollectToVec() Vec[K]

Collect to Vec

func (HashSetIter[K]) Filter added in v0.7.0

func (self HashSetIter[K]) Filter(f func(K) Bool) Iterator[K]

filter

func (HashSetIter[K]) Fold added in v0.7.0

func (self HashSetIter[K]) Fold(init K, f func(K, K) K) K

fold

func (HashSetIter[K]) Map added in v0.7.0

func (self HashSetIter[K]) Map(f func(K) K) Iterator[K]

map

func (*HashSetIter[K]) Next added in v0.7.0

func (self *HashSetIter[K]) Next() Option[K]

next

func (HashSetIter[K]) Rev added in v0.7.0

func (self HashSetIter[K]) Rev() Iterator[K]

rev

type I16 added in v0.6.0

type I16 int16

func (I16) Add added in v0.6.0

func (self I16) Add(rhs I16) I16

func (*I16) AddAssign added in v0.6.0

func (self *I16) AddAssign(rhs I16)

func (I16) Clone added in v0.6.0

func (self I16) Clone() I16

func (I16) Cmp added in v0.6.0

func (self I16) Cmp(rhs I16) Ordering

func (I16) Debug added in v0.6.0

func (self I16) Debug() String

func (I16) Display added in v0.6.0

func (self I16) Display() String

func (I16) Div added in v0.6.0

func (self I16) Div(rhs I16) I16

func (*I16) DivAssign added in v0.6.0

func (self *I16) DivAssign(rhs I16)

func (I16) Eq added in v0.6.0

func (self I16) Eq(rhs I16) Bool

func (I16) Mul added in v0.6.0

func (self I16) Mul(rhs I16) I16

func (*I16) MulAssign added in v0.6.0

func (self *I16) MulAssign(rhs I16)

func (I16) Sub added in v0.6.0

func (self I16) Sub(rhs I16) I16

func (*I16) SubAssign added in v0.6.0

func (self *I16) SubAssign(rhs I16)

func (I16) ToString added in v0.6.0

func (self I16) ToString() String

type I32 added in v0.6.0

type I32 int32

func (I32) Add added in v0.6.0

func (self I32) Add(rhs I32) I32

func (*I32) AddAssign added in v0.6.0

func (self *I32) AddAssign(rhs I32)

func (I32) Clone added in v0.6.0

func (self I32) Clone() I32

func (I32) Cmp added in v0.6.0

func (self I32) Cmp(rhs I32) Ordering

func (I32) Debug added in v0.6.0

func (self I32) Debug() String

func (I32) Display added in v0.6.0

func (self I32) Display() String

func (I32) Div added in v0.6.0

func (self I32) Div(rhs I32) I32

func (*I32) DivAssign added in v0.6.0

func (self *I32) DivAssign(rhs I32)

func (I32) Eq added in v0.6.0

func (self I32) Eq(rhs I32) Bool

func (I32) Mul added in v0.6.0

func (self I32) Mul(rhs I32) I32

func (*I32) MulAssign added in v0.6.0

func (self *I32) MulAssign(rhs I32)

func (I32) Sub added in v0.6.0

func (self I32) Sub(rhs I32) I32

func (*I32) SubAssign added in v0.6.0

func (self *I32) SubAssign(rhs I32)

func (I32) ToString added in v0.6.0

func (self I32) ToString() String

type I64 added in v0.6.0

type I64 int64

func (I64) Add added in v0.6.0

func (self I64) Add(rhs I64) I64

func (*I64) AddAssign added in v0.6.0

func (self *I64) AddAssign(rhs I64)

func (I64) Clone added in v0.6.0

func (self I64) Clone() I64

func (I64) Cmp added in v0.6.0

func (self I64) Cmp(rhs I64) Ordering

func (I64) Debug added in v0.6.0

func (self I64) Debug() String

func (I64) Display added in v0.6.0

func (self I64) Display() String

func (I64) Div added in v0.6.0

func (self I64) Div(rhs I64) I64

func (*I64) DivAssign added in v0.6.0

func (self *I64) DivAssign(rhs I64)

func (I64) Eq added in v0.6.0

func (self I64) Eq(rhs I64) Bool

func (I64) Mul added in v0.6.0

func (self I64) Mul(rhs I64) I64

func (*I64) MulAssign added in v0.6.0

func (self *I64) MulAssign(rhs I64)

func (I64) Sub added in v0.6.0

func (self I64) Sub(rhs I64) I64

func (*I64) SubAssign added in v0.6.0

func (self *I64) SubAssign(rhs I64)

func (I64) ToString added in v0.6.0

func (self I64) ToString() String

type I8 added in v0.6.0

type I8 int8

func (I8) Add added in v0.6.0

func (self I8) Add(rhs I8) I8

func (*I8) AddAssign added in v0.6.0

func (self *I8) AddAssign(rhs I8)

func (I8) Clone added in v0.6.0

func (self I8) Clone() I8

func (I8) Cmp added in v0.6.0

func (self I8) Cmp(rhs I8) Ordering

func (I8) Debug added in v0.6.0

func (self I8) Debug() String

func (I8) Display added in v0.6.0

func (self I8) Display() String

func (I8) Div added in v0.6.0

func (self I8) Div(rhs I8) I8

func (*I8) DivAssign added in v0.6.0

func (self *I8) DivAssign(rhs I8)

func (I8) Eq added in v0.6.0

func (self I8) Eq(rhs I8) Bool

func (I8) Mul added in v0.6.0

func (self I8) Mul(rhs I8) I8

func (*I8) MulAssign added in v0.6.0

func (self *I8) MulAssign(rhs I8)

func (I8) Sub added in v0.6.0

func (self I8) Sub(rhs I8) I8

func (*I8) SubAssign added in v0.6.0

func (self *I8) SubAssign(rhs I8)

func (I8) ToString added in v0.6.0

func (self I8) ToString() String

type ISize added in v0.6.0

type ISize int

func (ISize) Add added in v0.6.0

func (self ISize) Add(rhs ISize) ISize

Add implements

func (*ISize) AddAssign added in v0.6.0

func (self *ISize) AddAssign(rhs ISize)

AddAssign implements

func (ISize) Clone added in v0.6.0

func (self ISize) Clone() ISize

func (ISize) Cmp added in v0.6.0

func (self ISize) Cmp(rhs ISize) Ordering

func (ISize) Debug added in v0.6.0

func (self ISize) Debug() String

func (ISize) Display added in v0.6.0

func (self ISize) Display() String

func (ISize) Div added in v0.6.0

func (self ISize) Div(rhs ISize) ISize

Div implements

func (*ISize) DivAssign added in v0.6.0

func (self *ISize) DivAssign(rhs ISize)

DivAssign implements

func (ISize) Eq added in v0.6.0

func (self ISize) Eq(rhs ISize) Bool

func (ISize) Mul added in v0.6.0

func (self ISize) Mul(rhs ISize) ISize

Mul implements

func (*ISize) MulAssign added in v0.6.0

func (self *ISize) MulAssign(rhs ISize)

MulAssign implements

func (ISize) Sub added in v0.6.0

func (self ISize) Sub(rhs ISize) ISize

Sub implements

func (*ISize) SubAssign added in v0.6.0

func (self *ISize) SubAssign(rhs ISize)

SubAssign implements

func (ISize) ToString added in v0.6.0

func (self ISize) ToString() String

type IntoIterator

type IntoIterator[T any] interface {
	IntoIter() Iterator[T]
}

type Iterator

type Iterator[T any] interface {
	Next() Option[T]
	Map(f func(T) T) Iterator[T]
	Filter(f func(T) Bool) Iterator[T]
	Fold(init T, f func(T, T) T) T
	Rev() Iterator[T]
	CollectToVec() Vec[T]
	CollectToLinkedList() LinkedList[T]
}

type LinkedList added in v0.5.0

type LinkedList[T any] struct {
	// contains filtered or unexported fields
}

func LinkedListNew added in v0.5.0

func LinkedListNew[T any]() LinkedList[T]

Creates an empty LinkedList.

func (*LinkedList[T]) Append added in v0.5.0

func (list *LinkedList[T]) Append(other *LinkedList[T])

Moves all elements from other to the end of the list. This reuses all the nodes from other and moves them into self. After this operation, other becomes empty. This operation should compute in O(1) time and O(1) memory.

func (*LinkedList[T]) Back added in v0.5.0

func (list *LinkedList[T]) Back() Option[*T]

Provides a reference to the back element, or None if the list is empty. This operation should compute in O(1) time.

func (*LinkedList[T]) Clear added in v0.5.0

func (list *LinkedList[T]) Clear()

Removes all elements from the LinkedList. This operation should compute in O(1) time. +GC

func (LinkedList[T]) Debug added in v0.5.0

func (self LinkedList[T]) Debug() String

impl Debug for LinkedList

func (LinkedList[T]) Display added in v0.5.0

func (self LinkedList[T]) Display() String

impl Display for LinkedList

func (*LinkedList[T]) Front added in v0.5.0

func (list *LinkedList[T]) Front() Option[*T]

Provides a reference to the front element, or None if the list is empty. This operation should compute in O(1) time.

func (*LinkedList[T]) IntoIter added in v0.5.0

func (list *LinkedList[T]) IntoIter() Iterator[T]

into_iter

func (LinkedList[T]) IsEmpty added in v0.5.0

func (list LinkedList[T]) IsEmpty() Bool

Returns true if the LinkedList is empty. This operation should compute in O(1) time.

func (LinkedList[T]) Len added in v0.5.0

func (list LinkedList[T]) Len() USize

Returns the length of the LinkedList. This operation should compute in O(1) time.

func (*LinkedList[T]) PopBack added in v0.5.0

func (list *LinkedList[T]) PopBack() Option[T]

Removes the last element from a list and returns it, or None if it is empty. This operation should compute in O(1) time.

func (*LinkedList[T]) PopFront added in v0.5.0

func (list *LinkedList[T]) PopFront() Option[T]

Removes the first element and returns it, or None if the list is empty. This operation should compute in O(1) time.

func (*LinkedList[T]) PushBack added in v0.5.0

func (list *LinkedList[T]) PushBack(value T)

Appends an element to the back of a list. This operation should compute in O(1) time.

func (*LinkedList[T]) PushFront added in v0.5.0

func (list *LinkedList[T]) PushFront(value T)

Adds an element first in the list. This operation should compute in O(1) time.

type LinkedListIter added in v0.5.0

type LinkedListIter[T any] struct {
	// contains filtered or unexported fields
}

func (LinkedListIter[T]) CollectToLinkedList added in v0.6.0

func (self LinkedListIter[T]) CollectToLinkedList() LinkedList[T]

func (LinkedListIter[T]) CollectToVec added in v0.5.0

func (self LinkedListIter[T]) CollectToVec() Vec[T]

func (LinkedListIter[T]) Filter added in v0.5.0

func (self LinkedListIter[T]) Filter(f func(T) Bool) Iterator[T]

filter

func (LinkedListIter[T]) Fold added in v0.5.0

func (self LinkedListIter[T]) Fold(init T, f func(T, T) T) T

fold

func (LinkedListIter[T]) Map added in v0.5.0

func (self LinkedListIter[T]) Map(f func(T) T) Iterator[T]

map

func (*LinkedListIter[T]) Next added in v0.5.0

func (self *LinkedListIter[T]) Next() Option[T]

next

func (LinkedListIter[T]) Rev added in v0.5.0

func (self LinkedListIter[T]) Rev() Iterator[T]

rev

type LinkedListNode added in v0.5.0

type LinkedListNode[T any] struct {
	// contains filtered or unexported fields
}

type Mul

type Mul[T any] interface {
	Mul(rhs T) T
}

Mul is a trait for types that support multiplication.

type MulAssign

type MulAssign[T any] interface {
	MulAssign(rhs T)
}

The multiplication assignment operator *=.

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func None

func None[T any]() Option[T]

func Some

func Some[T any](value T) Option[T]

func (Option[T]) And

func (self Option[T]) And(optb Option[any]) Option[any]

Returns None if the option is None, otherwise returns optb. Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use and_then, which is lazily evaluated.

func (Option[T]) AndThen

func (self Option[T]) AndThen(f func(T) Option[any]) Option[any]

Returns None if the option is None, otherwise calls f with the wrapped value and returns the result. Some languages call this operation flatmap.

func (Option[T]) Debug

func (self Option[T]) Debug() String

impl Debug for Option

func (Option[T]) Display

func (self Option[T]) Display() String

impl Display for Option

func (Option[T]) Expect

func (self Option[T]) Expect(message string) T

Returns the contained Some value, consuming the self value.

func (Option[T]) Filter

func (self Option[T]) Filter(predicate func(T) Bool) Option[T]

Returns None if the option is None, otherwise calls predicate with the wrapped value and returns: 1. Some(t) if predicate returns true (where t is the wrapped value), and 2. None if predicate returns false.

func (*Option[T]) GetOrInsert

func (self *Option[T]) GetOrInsert(value T) *T

Inserts value into the option if it is None, then returns a mutable reference to the contained value. See also Option::insert, which updates the value even if the option already contains Some.

func (*Option[T]) GetOrInsertWith

func (self *Option[T]) GetOrInsertWith(f func() T) *T

Inserts a value computed from f into the option if it is None, then returns a mutable reference to the contained value.

func (*Option[T]) Insert

func (self *Option[T]) Insert(value T) *T

Inserts value into the option, then returns a mutable reference to it. If the option already contains a value, the old value is dropped. See also Option::get_or_insert, which doesn’t update the value if the option already contains Some.

func (Option[T]) IsNone

func (self Option[T]) IsNone() Bool

Returns true if the option is a None value.

func (Option[T]) IsSome

func (self Option[T]) IsSome() Bool

Returns true if the option is a Some value.

func (*Option[T]) IsSomeAnd

func (self *Option[T]) IsSomeAnd(f func(T) Bool) Bool

Returns true if the option is a Some and the value inside of it matches a predicate.

func (Option[T]) Map

func (self Option[T]) Map(f func(T) T) Option[T]

Maps an Option<T> to other Option<T> by applying a function to a contained value (if Some) or returns None (if None).

func (Option[T]) MapOr

func (self Option[T]) MapOr(defaultValue T, f func(T) T) T

Returns the provided default result (if none), or applies a function to the contained value (if any). Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use map_or_else, which is lazily evaluated.

func (Option[T]) MapOrElse

func (self Option[T]) MapOrElse(defaultValue func() T, f func(T) T) T

Computes a default function result (if none), or applies a different function to the contained value (if any).

func (Option[T]) Or

func (self Option[T]) Or(optb Option[T]) Option[T]

Returns the option if it contains a value, otherwise returns optb. Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use or_else, which is lazily evaluated.

func (Option[T]) OrElse

func (self Option[T]) OrElse(f func() Option[T]) Option[T]

Returns the option if it contains a value, otherwise calls f and returns the result.

func (*Option[T]) Replace

func (self *Option[T]) Replace(value T) Option[T]

Replaces the actual value in the option by the value given in parameter, returning the old value if present, leaving a Some in its place without deinitializing either one.

func (*Option[T]) Take

func (self *Option[T]) Take() Option[T]

Takes the value out of the option, leaving a None in its place.

func (Option[T]) Unwrap

func (self Option[T]) Unwrap() T

Returns the contained Some value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the None case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.

func (Option[T]) UnwrapOr

func (self Option[T]) UnwrapOr(value T) T

Returns the contained Some value or a provided default. Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.

func (Option[T]) UnwrapOrElse

func (self Option[T]) UnwrapOrElse(f func() T) T

Returns the contained Some value or computes it from a closure.

func (Option[T]) Xor

func (self Option[T]) Xor(optb Option[T]) Option[T]

Returns Some if exactly one of self, optb is Some, otherwise returns None.

type Ord

type Ord[T any] interface {
	Cmp(rhs T) Ordering
}

type Ordering

type Ordering int
const OrderingEqual Ordering = Ordering(0)
const OrderingGreater Ordering = Ordering(1)
const OrderingLess Ordering = Ordering(-1)

Ordering enum values

type Pair

type Pair[K any, V any] struct {
	Key   K
	Value V
}

func (Pair[K, V]) Clone added in v0.7.0

func (p Pair[K, V]) Clone() Pair[K, V]

impl Clone for Pair

func (Pair[K, V]) Cmp added in v0.7.0

func (p Pair[K, V]) Cmp(other Pair[K, V]) Ordering

impl Ord for Pair

func (Pair[K, V]) Debug added in v0.7.0

func (p Pair[K, V]) Debug() string

impl Debug for Pair

func (Pair[K, V]) Eq added in v0.7.0

func (p Pair[K, V]) Eq(other Pair[K, V]) Bool

impl Eq for Pair

func (Pair[K, V]) String added in v0.7.0

func (p Pair[K, V]) String() string

impl Display for Pair

func (Pair[K, V]) ToString added in v0.7.0

func (p Pair[K, V]) ToString() string

impl Display for Pair

type Result

type Result[T any] struct {
	// contains filtered or unexported fields
}

func Copy

func Copy(from String, to String) Result[any]

Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file. This function will overwrite the contents of to.

func CreateDir

func CreateDir(path String) Result[any]

Creates a new, empty directory at the provided path

func Err

func Err[T any](err error) Result[T]

func Ok

func Ok[T any](value T) Result[T]

func Read

func Read(path String) Result[[]Byte]

Read the entire contents of a file into a bytes vector.

func ReadDir

func ReadDir(path String) Result[Vec[DirEntry]]

Returns an iterator over the entries within a directory.

func ReadToString

func ReadToString(path String) Result[String]

Read the entire contents of a file into a string.

func RemoveDir

func RemoveDir(path String) Result[any]

Removes an empty directory.

func RemoveFile

func RemoveFile(path String) Result[any]

Removes a file from the filesystem.

func Rename

func Rename(from String, to String) Result[any]

Rename a file or directory to a new name, replacing the original file if to already exists. This will not work if the new name is on a different mount point.

func Write

func Write(path String, data []Byte) Result[any]

Write a slice as the entire contents of a file.

func (Result[T]) And

func (self Result[T]) And(res Result[T]) Result[T]

Returns res if the result is Ok, otherwise returns the Err value of self. Arguments passed to and are eagerly evaluated; if you are passing the result of a function call, it is recommended to use and_then, which is lazily evaluated.

func (Result[T]) AndThen

func (self Result[T]) AndThen(op func(T) Result[T]) Result[T]

Calls op if the result is Ok, otherwise returns the Err value of self. This function can be used for control flow based on Result values.

func (Result[T]) Debug

func (self Result[T]) Debug() String

impl Debug for Result

func (Result[T]) Display

func (self Result[T]) Display() String

impl Display for Result

func (Result[T]) Err

func (self Result[T]) Err() Option[error]

Converts from Result<T, E> to Option<E>. Converts self into an Option<E>, consuming self, and discarding the success value, if any.

func (Result[T]) Expect

func (self Result[T]) Expect(message string) T

Returns the contained Ok value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the Err case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.

func (Result[T]) ExpectErr

func (self Result[T]) ExpectErr(message string) error

Returns the contained Err value, consuming the self value.

func (Result[T]) IsErr

func (self Result[T]) IsErr() Bool

Returns true if the result is Err.

func (Result[T]) IsErrAnd

func (self Result[T]) IsErrAnd(predicate func(error) Bool) Bool

Returns true if the result is Err and the value inside of it matches a predicate.

func (Result[T]) IsOk

func (self Result[T]) IsOk() Bool

Returns true if the result is Ok.

func (Result[T]) IsOkAnd

func (self Result[T]) IsOkAnd(predicate func(T) Bool) Bool

Returns true if the result is Ok and the value inside of it matches a predicate.

func (Result[T]) Map

func (self Result[T]) Map(f func(T) T) Result[T]

Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched. This function can be used to compose the results of two functions.

func (Result[T]) MapErr

func (self Result[T]) MapErr(f func(error) error) Result[T]

Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched. This function can be used to pass through a successful result while handling an error.

func (Result[T]) MapOr

func (self Result[T]) MapOr(defaultValue T, f func(T) T) T

Returns the provided default (if Err), or applies a function to the contained value (if Ok), Arguments passed to map_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use map_or_else, which is lazily evaluated.

func (Result[T]) MapOrElse

func (self Result[T]) MapOrElse(defaultValue func() T, f func(T) T) T

Maps a Result<T, E> to U by applying fallback function default to a contained Err value, or function f to a contained Ok value. This function can be used to unpack a successful result while handling an error.

func (Result[T]) Ok

func (self Result[T]) Ok() Option[T]

Converts from Result<T, E> to Option<T>. Converts self into an Option<T>, consuming self, and discarding the error, if any.

func (Result[T]) Or

func (self Result[T]) Or(res Result[T]) Result[T]

Returns res if the result is Err, otherwise returns the Ok value of self. Arguments passed to or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use or_else, which is lazily evaluated.

func (Result[T]) OrElse

func (self Result[T]) OrElse(op func(error) Result[T]) Result[T]

Calls op if the result is Err, otherwise returns the Ok value of self. This function can be used for control flow based on result values.

func (Result[T]) Unwrap

func (self Result[T]) Unwrap() T

Returns the contained Ok value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the Err case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default.

func (Result[T]) UnwrapErr

func (self Result[T]) UnwrapErr() error

Returns the contained Err value, consuming the self value.

func (Result[T]) UnwrapOr

func (self Result[T]) UnwrapOr(defaultValue T) T

Returns the contained Ok value or a provided default. Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.

func (Result[T]) UnwrapOrElse

func (self Result[T]) UnwrapOrElse(f func() T) T

Returns the contained Ok value or computes it from a closure.

type Stdin

type Stdin struct {
	// contains filtered or unexported fields
}

func (*Stdin) Lock

func (self *Stdin) Lock() *sync.Mutex

Locks this handle to the standard input stream, returning a readable guard.

func (*Stdin) ReadLine

func (self *Stdin) ReadLine(buffer *String)

Locks this handle and reads a line of input, appending it to the specified buffer.

type String

type String string

func Format

func Format(format String, params ...any) String

func (String) Add added in v0.6.0

func (self String) Add(rhs String) String

func (*String) AddAssign added in v0.6.0

func (self *String) AddAssign(rhs String)

func (String) Clone

func (self String) Clone() String

func (String) Cmp

func (self String) Cmp(rhs String) Ordering

func (String) Debug

func (self String) Debug() String

func (String) Display

func (self String) Display() String

func (String) Eq

func (self String) Eq(rhs String) Bool

func (String) ToString

func (self String) ToString() String

type Sub

type Sub[T any] interface {
	Sub(rhs T) T
}

Sub is a trait for types that support subtraction.

type SubAssign

type SubAssign[T any] interface {
	SubAssign(rhs T)
}

The subtraction assignment operator -=.

type ToString

type ToString[T any] interface {
	ToString() String
}

A trait for converting a value to a String.

type U16 added in v0.6.0

type U16 uint16

func (U16) Add added in v0.6.0

func (self U16) Add(rhs U16) U16

func (*U16) AddAssign added in v0.6.0

func (self *U16) AddAssign(rhs U16)

func (U16) Clone added in v0.6.0

func (self U16) Clone() U16

func (U16) Cmp added in v0.6.0

func (self U16) Cmp(rhs U16) Ordering

func (U16) Debug added in v0.6.0

func (self U16) Debug() String

func (U16) Display added in v0.6.0

func (self U16) Display() String

func (U16) Div added in v0.6.0

func (self U16) Div(rhs U16) U16

func (*U16) DivAssign added in v0.6.0

func (self *U16) DivAssign(rhs U16)

func (U16) Eq added in v0.6.0

func (self U16) Eq(rhs U16) Bool

func (U16) Mul added in v0.6.0

func (self U16) Mul(rhs U16) U16

func (*U16) MulAssign added in v0.6.0

func (self *U16) MulAssign(rhs U16)

func (U16) Sub added in v0.6.0

func (self U16) Sub(rhs U16) U16

func (*U16) SubAssign added in v0.6.0

func (self *U16) SubAssign(rhs U16)

func (U16) ToString added in v0.6.0

func (self U16) ToString() String

type U32 added in v0.6.0

type U32 uint32

func (U32) Add added in v0.6.0

func (self U32) Add(rhs U32) U32

func (*U32) AddAssign added in v0.6.0

func (self *U32) AddAssign(rhs U32)

func (U32) Clone added in v0.6.0

func (self U32) Clone() U32

func (U32) Cmp added in v0.6.0

func (self U32) Cmp(rhs U32) Ordering

func (U32) Debug added in v0.6.0

func (self U32) Debug() String

func (U32) Display added in v0.6.0

func (self U32) Display() String

func (U32) Div added in v0.6.0

func (self U32) Div(rhs U32) U32

func (*U32) DivAssign added in v0.6.0

func (self *U32) DivAssign(rhs U32)

func (U32) Eq added in v0.6.0

func (self U32) Eq(rhs U32) Bool

func (U32) Mul added in v0.6.0

func (self U32) Mul(rhs U32) U32

func (*U32) MulAssign added in v0.6.0

func (self *U32) MulAssign(rhs U32)

func (U32) Sub added in v0.6.0

func (self U32) Sub(rhs U32) U32

func (*U32) SubAssign added in v0.6.0

func (self *U32) SubAssign(rhs U32)

func (U32) ToString added in v0.6.0

func (self U32) ToString() String

type U64 added in v0.6.0

type U64 uint64

func (U64) Add added in v0.6.0

func (self U64) Add(rhs U64) U64

func (*U64) AddAssign added in v0.6.0

func (self *U64) AddAssign(rhs U64)

func (U64) Clone added in v0.6.0

func (self U64) Clone() U64

func (U64) Cmp added in v0.6.0

func (self U64) Cmp(rhs U64) Ordering

func (U64) Debug added in v0.6.0

func (self U64) Debug() String

func (U64) Display added in v0.6.0

func (self U64) Display() String

func (U64) Div added in v0.6.0

func (self U64) Div(rhs U64) U64

func (*U64) DivAssign added in v0.6.0

func (self *U64) DivAssign(rhs U64)

func (U64) Eq added in v0.6.0

func (self U64) Eq(rhs U64) Bool

func (U64) Mul added in v0.6.0

func (self U64) Mul(rhs U64) U64

func (*U64) MulAssign added in v0.6.0

func (self *U64) MulAssign(rhs U64)

func (U64) Sub added in v0.6.0

func (self U64) Sub(rhs U64) U64

func (*U64) SubAssign added in v0.6.0

func (self *U64) SubAssign(rhs U64)

func (U64) ToString added in v0.6.0

func (self U64) ToString() String

type U8 added in v0.6.0

type U8 uint8

func (U8) Add added in v0.6.0

func (self U8) Add(rhs U8) U8

func (*U8) AddAssign added in v0.6.0

func (self *U8) AddAssign(rhs U8)

func (U8) Clone added in v0.6.0

func (self U8) Clone() U8

func (U8) Cmp added in v0.6.0

func (self U8) Cmp(rhs U8) Ordering

func (U8) Debug added in v0.6.0

func (self U8) Debug() String

func (U8) Display added in v0.6.0

func (self U8) Display() String

func (U8) Div added in v0.6.0

func (self U8) Div(rhs U8) U8

func (*U8) DivAssign added in v0.6.0

func (self *U8) DivAssign(rhs U8)

func (U8) Eq added in v0.6.0

func (self U8) Eq(rhs U8) Bool

func (U8) Mul added in v0.6.0

func (self U8) Mul(rhs U8) U8

func (*U8) MulAssign added in v0.6.0

func (self *U8) MulAssign(rhs U8)

func (U8) Sub added in v0.6.0

func (self U8) Sub(rhs U8) U8

func (*U8) SubAssign added in v0.6.0

func (self *U8) SubAssign(rhs U8)

func (U8) ToString added in v0.6.0

func (self U8) ToString() String

type USize added in v0.6.0

type USize uint

func (USize) Add added in v0.6.0

func (self USize) Add(rhs USize) USize

func (*USize) AddAssign added in v0.6.0

func (self *USize) AddAssign(rhs USize)

func (USize) Clone added in v0.6.0

func (self USize) Clone() USize

func (USize) Cmp added in v0.6.0

func (self USize) Cmp(rhs USize) Ordering

func (USize) Debug added in v0.6.0

func (self USize) Debug() String

func (USize) Display added in v0.6.0

func (self USize) Display() String

func (USize) Div added in v0.6.0

func (self USize) Div(rhs USize) USize

func (*USize) DivAssign added in v0.6.0

func (self *USize) DivAssign(rhs USize)

func (USize) Eq added in v0.6.0

func (self USize) Eq(rhs USize) Bool

func (USize) Mul added in v0.6.0

func (self USize) Mul(rhs USize) USize

func (*USize) MulAssign added in v0.6.0

func (self *USize) MulAssign(rhs USize)

func (USize) Sub added in v0.6.0

func (self USize) Sub(rhs USize) USize

func (*USize) SubAssign added in v0.6.0

func (self *USize) SubAssign(rhs USize)

func (USize) ToString added in v0.6.0

func (self USize) ToString() String

type Vec

type Vec[T any] struct {
	// contains filtered or unexported fields
}

func VecNew

func VecNew[T any]() Vec[T]

Constructs a new, empty Vec<T>. The vector will not allocate until elements are pushed onto it.

func VecWithCapacity

func VecWithCapacity[T any](capacity USize) Vec[T]

Constructs a new, empty Vec<T> with at least the specified capacity.

func VecWithLen

func VecWithLen[T any](len USize) Vec[T]

Constructs a new, empty Vec<T> with at least the specified capacity.

func (*Vec[T]) Append

func (self *Vec[T]) Append(other *Vec[T])

Moves all the elements of other ISizeo self, leaving other empty.

func (Vec[T]) AsSlice

func (self Vec[T]) AsSlice() []T

Extracts a slice containing the entire vector.

func (Vec[T]) BinarySearch

func (self Vec[T]) BinarySearch(value T) Option[USize]

Binary searches this slice for a given element. If the slice is not sorted, the returned result is unspecified and meaningless.

func (Vec[T]) BinarySearchBy

func (self Vec[T]) BinarySearchBy(f func(T) Ordering) Option[USize]

Binary searches this slice with a comparator function. The comparator function should return an order code that indicates whether its argument is Less, Equal or Greater the desired target. If the slice is not sorted or if the comparator function does not implement an order consistent with the sort order of the underlying slice, the returned result is unspecified and meaningless.

func (Vec[T]) Capacity

func (self Vec[T]) Capacity() USize

Returns the total number of elements the vector can hold without reallocating.

func (*Vec[T]) Clear

func (self *Vec[T]) Clear()

Clears the vector, removing all values.

func (Vec[T]) Contains

func (self Vec[T]) Contains(value T) Bool

Returns true if the slice contains an element with the given value. This operation is O(n). Note that if you have a sorted slice, binary_search may be faster.

func (Vec[T]) Debug

func (self Vec[T]) Debug() String

impl Debug for Vec

func (*Vec[T]) Dedup

func (self *Vec[T]) Dedup()

Removes consecutive repeated elements in the vector according to the PartialEq trait implementation. If the vector is sorted, this removes all duplicates.

func (*Vec[T]) DedupByKey

func (self *Vec[T]) DedupByKey(key func(T) any)

Removes all but the first of consecutive elements in the vector that resolve to the same key. If the vector is sorted, this removes all duplicates.

func (Vec[T]) Display

func (self Vec[T]) Display() String

impl Display for Vec

func (*Vec[T]) Fill

func (self *Vec[T]) Fill(value T)

Fills self with elements by cloning value.

func (*Vec[T]) FillWith

func (self *Vec[T]) FillWith(f func() T)

Fills self with elements returned by calling a closure repeatedly.

func (Vec[T]) Get

func (self Vec[T]) Get(index USize) Option[T]

Returns a reference to an element or subslice depending on the type of index. If given a position, returns a reference to the element at that position or None if out of bounds. If given a range, returns the subslice corresponding to that range, or None if out of bounds.

func (Vec[T]) GetUnchecked

func (self Vec[T]) GetUnchecked(index USize) T

Returns a reference to an element or subslice, without doing bounds checking. For a safe alternative see get.

func (*Vec[T]) Insert

func (self *Vec[T]) Insert(index USize, value T)

Inserts an element at position index within the vector, shifting all elements after it to the right.

func (Vec[T]) IntoIter

func (self Vec[T]) IntoIter() Iterator[T]

into_iter

func (Vec[T]) IsEmpty

func (self Vec[T]) IsEmpty() Bool

Returns true if the vector contains no elements.

func (Vec[T]) Len

func (self Vec[T]) Len() USize

Returns the number of elements in the vector, also referred to as its ‘length’.

func (*Vec[T]) Pop

func (self *Vec[T]) Pop() Option[T]

Removes the last element from a vector and returns it, or None if it is empty.

func (*Vec[T]) Push

func (self *Vec[T]) Push(value T)

Appends an element to the back of a collection.

func (*Vec[T]) Reserve

func (self *Vec[T]) Reserve(additional USize)

Reserves capacity for at least additional more elements to be inserted in the given Vec<T>. The collection may reserve more space to speculatively avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.

func (*Vec[T]) Retain

func (self *Vec[T]) Retain(predicate func(T) Bool)

func (*Vec[T]) Reverse

func (self *Vec[T]) Reverse()

Reverses the order of elements in the slice, in place.

func (*Vec[T]) Set added in v0.7.0

func (self *Vec[T]) Set(index USize, value T) Option[T]

Set

func (*Vec[T]) SetUnchecked added in v0.7.0

func (self *Vec[T]) SetUnchecked(index USize, value T)

Set unchecked

func (*Vec[T]) Sort

func (self *Vec[T]) Sort()

Sorts the slice. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn’t allocate auxiliary memory. See sort_unstable.

func (*Vec[T]) SortBy

func (self *Vec[T]) SortBy(compare func(T, T) Ordering)

Sorts the slice with a comparator function. This sort is stable (i.e., does not reorder equal elements) and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.

func (*Vec[T]) SortUnstable

func (self *Vec[T]) SortUnstable()

Sorts the slice, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case.

func (*Vec[T]) SortUnstableBy

func (self *Vec[T]) SortUnstableBy(compare func(T, T) Ordering)

Sorts the slice with a comparator function, but might not preserve the order of equal elements. This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case. The comparator function must define a total ordering for the elements in the slice. If the ordering is not total, the order of the elements is unspecified. An order is a total order if it is (for all a, b and c): - total and antisymmetric: exactly one of a < b, a == b or a > b is true, and - transitive, a < b and b < c implies a < c. The same must hold for both == and >.

func (*Vec[T]) Swap

func (self *Vec[T]) Swap(a, b USize)

Swaps two elements in the slice. If a equals to b, it’s guaranteed that elements won’t change value.

type VecIter

type VecIter[T any] struct {
	// contains filtered or unexported fields
}

func (VecIter[T]) CollectToLinkedList added in v0.6.0

func (self VecIter[T]) CollectToLinkedList() LinkedList[T]

func (VecIter[T]) CollectToVec

func (self VecIter[T]) CollectToVec() Vec[T]

func (VecIter[T]) Filter

func (self VecIter[T]) Filter(f func(T) Bool) Iterator[T]

filter

func (VecIter[T]) Fold

func (self VecIter[T]) Fold(init T, f func(T, T) T) T

fold

func (VecIter[T]) Map

func (self VecIter[T]) Map(f func(T) T) Iterator[T]

map

func (*VecIter[T]) Next

func (self *VecIter[T]) Next() Option[T]

next

func (VecIter[T]) Rev

func (self VecIter[T]) Rev() Iterator[T]

rev

Jump to

Keyboard shortcuts

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