prelude library
rust_std comes with a variety of things in its standard library. However, if you had to manually import every single thing that you used, it would be very verbose. But importing a lot of things that a program never uses isn’t good either. A balance needs to be struck. The prelude is the list of things that rust_std should automatically imports into almost all projects. It’s kept as small as possible, and is focused on things, which are used in almost every single rust_std program.
Classes
-
ArrayChunks<
T> -
Returns an iterator over N elements of the iterator at a time.
The chunks do not overlap. If N does not divide the length of the iterator, then the last up to N-1 elements will
be omitted and can be retrieved from the
.intoRemainder()
function of the iterator. -
Cast<
S, T> -
Chain<
T> - Takes two iterators and creates a new iterator over both in sequence.
-
Clone<
T> - An iterator which is a "clone" of the original iterator. Iterating through the original or the clone will not affect the other. Note: Do not modify the original collection the original Iterable is based on while iterating. Explanation: Since Dart Iterators cannot be copied, Clone replaces the underlying iterator from the RIterator provided in the constructor with itself and collects any first calls to moveNext from any derived iterator. Due to this, modifications of the original iterable may have unintentional behavior on the cloned iterator. i.e. the first encounter of an object during iteration will be the one seen by the derived RIterator and all other subsequent Clones. Therefore if createing a Clone do not modify the original collection the passed in RIterator is based on.
-
Cycle<
T> - Creates an iterator which repeats the elements of the original iterator endlessly.
-
Err<
S, F extends Object> - Error Result.
-
ExtractIfIterable<
T> -
ExtractIfIterator<
T> - Creates an iterator which uses a closure to determine if an element should be removed. If the closure returns true, then the element is removed and yielded. If the closure returns false, the element will remain in the vector and will not be yielded by the iterator.
-
FlatMap<
S, T> - Maps each element of the original iterator to an iterator, and then flattens the result into a single iterator.
-
Ok<
S, F extends Object> - Ok Result.
-
Peekable<
T> - An iterator which can use the "peek" to look at the next element of the iterator without consuming it.
-
Result<
S, F extends Object> - Result is used for propagating errors and represents the sum type of Ok and Err.
-
RIterator<
T> - RIterator is the union between an Iterator and an Iterable. Most iterator methods are consuming and should be assumed to be so unless otherwise stated.
-
Slice<
T> - A contiguous sequence of elements in a List. Slices are a view into a list without allocating and copying to a new list, as such, they do not own their own data. Note: Shrinking the original list can cause the slices range to become invalid, which may cause an exception or unintended behavior.
-
SliceIterator<
T> - An iterator over the elements of a Slice.
-
Zip<
T, U> - Zips to iterators into a single iterator of pairs.
Extension Types
- Arr
-
A fixed-size array, denoted as
T; N
in Rust. - Option
-
Option represents the union of two types -
Some<T>
andNone
. As an extension type ofT?
,Option<T>
has the same runtime cost ofT?
with the advantage of being able to chain null specific operations. - Some
-
Represents a value that is present. The erasure of this is
T
. - Vec
- A contiguous growable array type, written as Vec
Extensions
-
ArrayOnIterableExtension
on Iterable<
T> -
ArrayOnListExtension
on List<
T> -
FlattenExtension
on Result<
Result< S, F> , F> -
FlattenFutureExtension
on FutureResult<
Result< S, F> , F> -
FutureIterableFutureResultExtensions
on Future<
Iterable< FutureResult< >S, F> > -
FutureIterableResultExtensions
on Future<
Iterable< Result< >S, F> > -
FutureOptionExtension
on FutureOption<
T> - FutureOption represents an asynchronous Option. And as such, inherits all of Option's methods.
-
FutureOptionOptionExtension
on FutureOption<
Option< T> > -
FutureOptionRecord2Extension
on FutureOption<
(T, U)> -
FutureOptionResultExtension
on FutureOption<
Result< S?, F> > -
FutureResultExtension
on FutureResult<
S, F> - FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
-
FutureResultNullExtension
on Future<
Result< S?, F> > -
FutureResultOptionExtension
on Future<
Result< Option< >S?> , F> -
FutureToOption
on Future<
T?> -
InfallibleErrExtension
on Result<
Never, F> -
InfallibleFutureErrExtension
on FutureResult<
Never, F> -
InfallibleFutureOkExtension
on FutureResult<
S, Never> -
InfallibleOkExtension
on Result<
S, Never> -
IterableExtension
on Iterable<
T> -
IterableExtensionsOverrides
on RIterator<
T> - Overrides built in extension methods on Iterable.
-
IterableFutureResultExtensions
on Iterable<
FutureResult< S, F> > -
IterableResultExtensions
on Iterable<
Result< S, F> > -
IteratorComparable
on RIterator<
T> -
IteratorComparableSelf
on RIterator<
T> -
IteratorExtension
on Iterator<
T> -
IteratorOnIteratorIterable
on RIterator<
Iterable< T> > -
IteratorOnIteratorTUExtension
on RIterator<
(T, U)> -
IteratorOptionExtension
on RIterator<
Option< T> > -
IteratorResultExtension
on RIterator<
Result< T, E> > -
IteratorResultFuncExtension
on RIterator<
T> - NoneMethodsExtension on _None
-
NullableIterableExtensionsOverrides
on RIterator<
T?> - Overrides built in extension methods on nullable Iterable.
-
NullResultExtension
on Result<
S, F> ? -
OptionMethodsExtension
on Option<
T> -
OptionNullableExtension
on Option<
T?> -
OptionOptionExtension
on Option<
Option< T> > -
OptionRecord2Extension
on Option<
(T, U)> -
OptionResultExtension
on Option<
Result< S?, F> > -
OptionToFutureOption
on Option<
T> -
RecordFunctionToResult10
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function(), Result<I, Z> Function(), Result<J, Z> Function()) -
RecordFunctionToResult2
on (Result<
A, Z> Function(), Result<B, Z> Function()) -
RecordFunctionToResult3
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function()) -
RecordFunctionToResult4
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function()) -
RecordFunctionToResult5
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function()) -
RecordFunctionToResult6
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function()) -
RecordFunctionToResult7
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function()) -
RecordFunctionToResult8
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function()) -
RecordFunctionToResult9
on (Result<
A, Z> Function(), Result<B, Z> Function(), Result<C, Z> Function(), Result<D, Z> Function(), Result<E, Z> Function(), Result<F, Z> Function(), Result<G, Z> Function(), Result<H, Z> Function(), Result<I, Z> Function()) -
RecordToResult10
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> , Result<F, Z> , Result<G, Z> , Result<H, Z> , Result<I, Z> , Result<J, Z> ) -
RecordToResult2
on (Result<
A, Z> , Result<B, Z> ) -
RecordToResult3
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> ) -
RecordToResult4
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> ) -
RecordToResult5
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> ) -
RecordToResult6
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> , Result<F, Z> ) -
RecordToResult7
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> , Result<F, Z> , Result<G, Z> ) -
RecordToResult8
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> , Result<F, Z> , Result<G, Z> , Result<H, Z> ) -
RecordToResult9
on (Result<
A, Z> , Result<B, Z> , Result<C, Z> , Result<D, Z> , Result<E, Z> , Result<F, Z> , Result<G, Z> , Result<H, Z> , Result<I, Z> ) -
ResultFutureToFutureResultExtension
on Result<
Future< S> , F> -
ResultNullExtension
on Result<
S?, F> -
ResultOptionExtension
on Result<
Option< S?> , F> -
ResultToFutureResultExtension
on Result<
S, F> -
SliceOnComparableSliceExtension
on Slice<
T> -
SliceOnListExtension
on List<
T> -
SliceOnSliceIntExtension
on Slice<
T> -
SomeMethodsExtension
on Some<
T> - ToErrExtension on E
- ToOkExtension on S
-
VecOnIterableExtension
on Iterable<
T> -
VecOnIteratorExtension
on Iterator<
T> -
VecOnListExtension
on List<
T> -
VecOnListListExtension
on List<
List< T> > -
VecOnListVecExtension
on List<
Vec< T> > -
VecOnVecListExtension
on Vec<
List< T> > -
VecOnVecVecExtension
on Vec<
Vec< T> > -
VecSetExtension
on Set<
T>
Constants
- None → const _None
-
Represents a value that is absent. The erasure of this is
null
.
Functions
-
guard<
S> (S func()) → Result< S, Object> -
Executes the function in a protected context.
func
is called inside a try catch block. If the result does not catch, then return valuefunc
returned inside an Ok. Iffunc
throws, then the thrown value is returned inside an Err. -
guardAsync<
S> (Future< S> func()) → FutureResult<S, Object> - Async version of guard
-
guardAsyncResult<
S> (Future< Result< func()) → FutureResult<S, Object> >S, Object> - Async version of guardResult
-
guardResult<
S> (Result< S, Object> func()) → Result<S, Object> -
Result unwrapping version of guard. Where
func
returns an Result, but can still throw. -
panic(
[String? msg]) → Never - Shorthand for
-
range(
int start, int end, {bool sInc = true, bool eInc = false}) → Arr< int> -
An array of ints in the range start..end contains all values with start <= x < end.
The edge conditions can be changes with
sInc
andeInc
.sInc
is whether the start is inclusive andeInc
is whether the end is inclusive. -
unreachable(
[String msg = "This code should be unreachable."]) → Never - Shorthand for
Typedefs
-
FutureOption<
T> = Future< Option< T> > - FutureOption represents an asynchronous Option. And as such, inherits all of Option's methods.
-
FutureResult<
S, F extends Object> = Future< Result< S, F> > - FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
Exceptions / Errors
- GetManyError
- GetManyErrorRequestedIndexOutOfBounds
- Panic
-
As with Error, Panic represents a state that should never happen and thus is not expected to be catch.
This is closely tied to the
unwrap
method of both Option and Result types. - Unreachable
- Indicates unreachable code. This is useful any time that the compiler can’t determine that some code is unreachable. For example: