Documentation ¶
Index ¶
- func Print(format String, params ...any)
- func Println(format String, params ...any)
- type Add
- type AddAssign
- type Any
- type Bool
- type Byte
- type Clone
- type Complex128
- type Complex64
- type Debug
- type Default
- type DirEntry
- type Display
- type Div
- type DivAssign
- type Eq
- type Error
- type FileType
- type Float32
- type Float64
- type HashMap
- func (self HashMap[K, V]) AsMap() map[K]V
- func (self *HashMap[K, V]) Clear()
- func (self HashMap[K, V]) ContainsKey(key K) Bool
- func (self HashMap[K, V]) Debug() String
- func (self HashMap[K, V]) Display() String
- func (self HashMap[K, V]) Get(key K) Option[V]
- func (self *HashMap[K, V]) Insert(key K, value V) Option[V]
- func (self HashMap[K, V]) IntoIter() Iterator[Pair[K, V]]
- func (self HashMap[K, V]) IsEmpty() Bool
- func (self HashMap[K, V]) Keys() Iterator[K]
- func (self HashMap[K, V]) Len() Int
- func (self *HashMap[K, V]) Remove(key K) Option[V]
- func (self HashMap[K, V]) Values() Iterator[V]
- type HashMapIter
- func (self HashMapIter[K, V]) CollectToVec() Vec[Pair[K, V]]
- func (self HashMapIter[K, V]) Filter(f func(Pair[K, V]) Bool) Iterator[Pair[K, V]]
- func (self HashMapIter[K, V]) Fold(init Pair[K, V], f func(Pair[K, V], Pair[K, V]) Pair[K, V]) Pair[K, V]
- func (self HashMapIter[K, V]) Map(f func(Pair[K, V]) Pair[K, V]) Iterator[Pair[K, V]]
- func (self *HashMapIter[K, V]) Next() Option[Pair[K, V]]
- func (self HashMapIter[K, V]) Rev() Iterator[Pair[K, V]]
- type HashMapKeys
- func (self HashMapKeys[K]) CollectToVec() Vec[K]
- func (self HashMapKeys[K]) Filter(f func(K) Bool) Iterator[K]
- func (self HashMapKeys[K]) Fold(init K, f func(K, K) K) K
- func (self HashMapKeys[K]) Map(f func(K) K) Iterator[K]
- func (self *HashMapKeys[K]) Next() Option[K]
- func (self HashMapKeys[K]) Rev() Iterator[K]
- type HashMapValues
- func (self HashMapValues[V]) CollectToVec() Vec[V]
- func (self HashMapValues[V]) Filter(f func(V) Bool) Iterator[V]
- func (self HashMapValues[V]) Fold(init V, f func(V, V) V) V
- func (self HashMapValues[V]) Map(f func(V) V) Iterator[V]
- func (self *HashMapValues[V]) Next() Option[V]
- func (self HashMapValues[V]) Rev() Iterator[V]
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type IntoIterator
- type Iterator
- type Mul
- type MulAssign
- type Option
- func (self Option[T]) And(optb Option[any]) Option[any]
- func (self Option[T]) AndThen(f func(T) Option[any]) Option[any]
- func (self Option[T]) Debug() String
- func (self Option[T]) Display() String
- func (self Option[T]) Expect(message string) T
- func (self Option[T]) Filter(predicate func(T) Bool) Option[T]
- func (self *Option[T]) GetOrInsert(value T) *T
- func (self *Option[T]) GetOrInsertWith(f func() T) *T
- func (self *Option[T]) Insert(value T) *T
- func (self *Option[T]) IsNone() Bool
- func (self *Option[T]) IsSome() Bool
- func (self *Option[T]) IsSomeAnd(f func(T) Bool) Bool
- func (self Option[T]) Map(f func(T) T) Option[T]
- func (self Option[T]) MapOr(defaultValue T, f func(T) T) T
- func (self Option[T]) MapOrElse(defaultValue func() T, f func(T) T) T
- func (self Option[T]) Or(optb Option[T]) Option[T]
- func (self Option[T]) OrElse(f func() Option[T]) Option[T]
- func (self *Option[T]) Replace(value T) Option[T]
- func (self *Option[T]) Take() Option[T]
- func (self Option[T]) Unwrap() T
- func (self Option[T]) UnwrapOr(value T) T
- func (self Option[T]) UnwrapOrElse(f func() T) T
- func (self Option[T]) Xor(optb Option[T]) Option[T]
- type Ord
- type Ordering
- type Pair
- type Result
- func Copy(from String, to String) Result[any]
- func CreateDir(path String) Result[any]
- func Err[T any](err error) Result[T]
- func Ok[T any](value T) Result[T]
- func Read(path String) Result[[]Byte]
- func ReadDir(path String) Result[Vec[DirEntry]]
- func ReadToString(path String) Result[String]
- func RemoveDir(path String) Result[any]
- func RemoveFile(path String) Result[any]
- func Rename(from String, to String) Result[any]
- func Write(path String, data []Byte) Result[any]
- func (self Result[T]) And(res Result[T]) Result[T]
- func (self Result[T]) AndThen(op func(T) Result[T]) Result[T]
- func (self Result[T]) Debug() String
- func (self Result[T]) Display() String
- func (self Result[T]) Err() Option[error]
- func (self Result[T]) Expect(message string) T
- func (self Result[T]) ExpectErr(message string) error
- func (self Result[T]) IsErr() Bool
- func (self Result[T]) IsErrAnd(predicate func(error) Bool) Bool
- func (self Result[T]) IsOk() Bool
- func (self Result[T]) IsOkAnd(predicate func(T) Bool) Bool
- func (self Result[T]) Map(f func(T) T) Result[T]
- func (self Result[T]) MapErr(f func(error) error) Result[T]
- func (self Result[T]) MapOr(defaultValue T, f func(T) T) T
- func (self Result[T]) MapOrElse(defaultValue func() T, f func(T) T) T
- func (self Result[T]) Ok() Option[T]
- func (self Result[T]) Or(res Result[T]) Result[T]
- func (self Result[T]) OrElse(op func(error) Result[T]) Result[T]
- func (self Result[T]) Unwrap() T
- func (self Result[T]) UnwrapErr() error
- func (self Result[T]) UnwrapOr(defaultValue T) T
- func (self Result[T]) UnwrapOrElse(f func() T) T
- type Rune
- type Stdin
- type String
- type Sub
- type SubAssign
- type ToString
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
- type Vec
- func (self *Vec[T]) Append(other *Vec[T])
- func (self Vec[T]) AsSlice() []T
- func (self Vec[T]) BinarySearch(value T) Option[Int]
- func (self Vec[T]) BinarySearchBy(f func(T) Ordering) Option[Int]
- func (self Vec[T]) Capacity() Int
- func (self *Vec[T]) Clear()
- func (self Vec[T]) Contains(value T) Bool
- func (self Vec[T]) Debug() String
- func (self *Vec[T]) Dedup()
- func (self *Vec[T]) DedupByKey(key func(T) any)
- func (self Vec[T]) Display() String
- func (self *Vec[T]) Fill(value T)
- func (self *Vec[T]) FillWith(f func() T)
- func (self Vec[T]) Get(index Int) Option[T]
- func (self Vec[T]) GetUnchecked(index Int) T
- func (self *Vec[T]) Insert(index Int, value T)
- func (self Vec[T]) IntoIter() Iterator[T]
- func (self Vec[T]) IsEmpty() Bool
- func (self Vec[T]) Len() Int
- func (self *Vec[T]) Pop() Option[T]
- func (self *Vec[T]) Push(value T)
- func (self *Vec[T]) Reserve(additional Int)
- func (self *Vec[T]) Retain(predicate func(T) Bool)
- func (self *Vec[T]) Reverse()
- func (self *Vec[T]) Sort()
- func (self *Vec[T]) SortBy(compare func(T, T) Ordering)
- func (self *Vec[T]) SortUnstable()
- func (self *Vec[T]) SortUnstableBy(compare func(T, T) Ordering)
- func (self *Vec[T]) Swap(a, b Int)
- type VecIter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Complex128 ¶
type Complex128 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) ToString ¶
func (self Complex128) ToString() String
type Default ¶
type Default[T any] interface { Default() T }
A trait for giving a type a useful default value.
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 HashMap ¶
type HashMap[K comparable, V any] struct { // contains filtered or unexported fields }
func HashMapWithCapacity ¶
func HashMapWithCapacity[K comparable, V any](capacity Int) HashMap[K, V]
Creates an empty HashMap with at least the specified capacity.
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 ¶
Returns true if the map contains a value for the specified key.
func (*HashMap[K, V]) Insert ¶
Inserts a key-value pair into the map. If the map did not have this key present, None is returned.
func (HashMap[K, V]) Keys ¶
An iterator visiting all keys in arbitrary order. The iterator element type is K.
type HashMapIter ¶
type HashMapIter[K comparable, V any] struct { // contains filtered or unexported fields }
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
type HashMapKeys ¶
type HashMapKeys[K any] struct { // contains filtered or unexported fields }
func (HashMapKeys[K]) CollectToVec ¶
func (self HashMapKeys[K]) CollectToVec() Vec[K]
type HashMapValues ¶
type HashMapValues[V any] struct { // contains filtered or unexported fields }
func (HashMapValues[V]) CollectToVec ¶
func (self HashMapValues[V]) CollectToVec() Vec[V]
func (HashMapValues[V]) Filter ¶
func (self HashMapValues[V]) Filter(f func(V) Bool) Iterator[V]
filter
type IntoIterator ¶
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 (Option[T]) And ¶
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 ¶
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]) Filter ¶
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]) IsSomeAnd ¶
Returns true if the option is a Some and the value inside of it matches a predicate.
func (Option[T]) Map ¶
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 ¶
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 ¶
Returns the option if it contains a value, otherwise calls f and returns the result.
func (*Option[T]) Replace ¶
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]) 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.
type Pair ¶
type Pair[K comparable, V any] struct { Key K Value V }
type Result ¶
type Result[T any] struct { // contains filtered or unexported fields }
func Copy ¶
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 ReadToString ¶
Read the entire contents of a file into a string.
func Rename ¶
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 (Result[T]) And ¶
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 ¶
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]) Err ¶
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 ¶
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]) IsErrAnd ¶
Returns true if the result is Err and the value inside of it matches a predicate.
func (Result[T]) IsOkAnd ¶
Returns true if the result is Ok and the value inside of it matches a predicate.
func (Result[T]) Map ¶
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 ¶
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 ¶
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 ¶
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 ¶
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]) 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
}
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 Vec ¶
type Vec[T any] struct { // contains filtered or unexported fields }
func VecNew ¶
Constructs a new, empty Vec<T>. The vector will not allocate until elements are pushed onto it.
func VecWithCapacity ¶
Constructs a new, empty Vec<T> with at least the specified capacity.
func VecWithLen ¶
Constructs a new, empty Vec<T> with at least the specified capacity.
func (Vec[T]) AsSlice ¶
func (self Vec[T]) AsSlice() []T
Extracts a slice containing the entire vector.
func (Vec[T]) BinarySearch ¶
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 ¶
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 ¶
Returns the total number of elements the vector can hold without reallocating.
func (Vec[T]) Contains ¶
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]) 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 ¶
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]) FillWith ¶
func (self *Vec[T]) FillWith(f func() T)
Fills self with elements returned by calling a closure repeatedly.
func (Vec[T]) Get ¶
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 ¶
Returns a reference to an element or subslice, without doing bounds checking. For a safe alternative see get.
func (*Vec[T]) Insert ¶
Inserts an element at position index within the vector, shifting all elements after it to the right.
func (*Vec[T]) Push ¶
func (self *Vec[T]) Push(value T)
Appends an element to the back of a collection.
func (*Vec[T]) Reserve ¶
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]) Reverse ¶
func (self *Vec[T]) Reverse()
Reverses the order of elements in the slice, in place.
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 ¶
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 ¶
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 >.
type VecIter ¶
type VecIter[T any] struct { // contains filtered or unexported fields }