Expand description
std_tools - Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind.
Module :: std_tools
Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind.
Sample :: implements
use std_tools::prelude::*;
fn main()
{
println!( "implements!( 13_i32 => Copy ) : {}", implements!( 13_i32 => Copy ) );
println!( "implements!( Box::new( 13_i32 ) => Copy ) : {}", implements!( Box::new( 13_i32 ) => Copy ) );
}
Sample :: type constructors
In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. To overcome the restriction developer usually wrap the external type into a tuple introducing a new type. Type constructor does exactly that and auto-implement traits From, Into, Deref and few more for the constructed type.
Macro types is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once.
use std_tools::prelude::*;
// types!
// {
//
// single MySingle : f32;
// single SingleWithParametrized : std::sync::Arc< T : Copy >;
// single SingleWithParameter : < T >;
//
// pair MyPair : f32;
// pair PairWithParametrized : std::sync::Arc< T1 : Copy >, std::sync::Arc< T2 : Copy >;
// pair PairWithParameter : < T1, T2 >;
//
// pair MyHomoPair : f32;
// pair HomoPairWithParametrized : std::sync::Arc< T : Copy >;
// pair HomoPairWithParameter : < T >;
//
// many MyMany : f32;
// many ManyWithParametrized : std::sync::Arc< T : Copy >;
// many ManyWithParameter : < T >;
//
// }
Modules
Dependencies.
Collection of primal data types
Exposed namespace of the module.
Iter tools.
Meta tools.
Orphan namespace of the module.
Prelude to use essentials: use my_module::prelude::*
.
Own namespace of the module.
Collection of general purpose time tools.
Type checking tools.
Macros
Internal impls1 macro. Don’t use.
Type constructor of many.
Pair type constructor.
Type constructor of single.
Literally just a BTreeMap literal with keys and values into’d.
Unwrap braces of token tree and pass its content to the passed callback. If token tree in not braced then it passed to callback as is.
Literally just a BTreeSet literal with values into’d.
Get name of a function.
Macro to rename function.
Split functions.
Split functions.
Module :: for_each
Literally just a BinaryHeap literal with values into’d.
Literally just a HashMap literal with keys and values into’d.
Literally just a HashSet literal with values into’d.
Macro which returns its input as is.
Macro implements
to answer the question: does it implement a trait?
Define implementation putting each function under a macro.
Define implementation putting each function under a macro.
Define implementation putting each function under a macro.
Macros to put each function under a named macro to index every function in a class.
Index of items.
Macro instance_of
to answer the question: does it implement a trait? Alias of the macro implements
.
Macro to answer the question: is it a slice?
Literally just a LinkedList literal with values into’d.
Variadic constructor.
Protocol of modularity unifying interface of a module.
Define implementation putting each function under a macro and adding attribute #[ test ]
.
Index of items.
Macro for unwrapping the left side of an Either
, which fails early
with the opposite side. Can only be used in functions that return
Either
because of the early return of Right
that it provides.
Dual to try_left!
, see its documentation for more information.
Type constructor to define tuple wrapping a given type.
Literally just a VecDeque literal with values into’d.
Structs
Type constructor to wrap pair of the same type.
Type constructor to wrap a another type into a tuple.
Type constructor to wrap two types into a tuple.
Type constructor to wrap a another type into a tuple.
Enums
The enum Either
with variants Left
and Right
is a general purpose
sum type with two cases.
Value that either holds a single A or B, or both.
An enum used for controlling the execution of fold_while
.
MinMaxResult
is an enum returned by minmax
.
A value yielded by WithPosition
.
Indicates the position of this element in the iterator results.
Traits
Reinterpret as array.
Reinterpret as slice.
Reinterpret as tuple.
Clone as array.
Clone as tuple.
Constructor without arguments.
Constructor with single argument.
Constructor with two arguments.
Constructor with three arguments.
An iterator that allows peeking at an element before deciding to accept it.
Functions
Test whether the predicate holds for all elements in the iterable.
Test whether the predicate holds for any elements in the iterable.
Assert that two iterables produce equal sequences, with the same
semantics as equal(a, b)
.
Create an iterator that first iterates i
and then j
.
Create an iterator that clones each element from &T to T
Create an iterator that maps for example iterators of
((A, B), C)
to (A, B, C)
.
Compares every element yielded by both i
and j
with the given function in lock-step and
returns a Diff
which describes how j
differs from i
.
Iterate iterable
with a running index.
Return true
if both iterables produce equal sequences
(elements pairwise equal and sequences of the same length),
false
otherwise.
Perform a fold operation over the iterable.
Create an iterator that interleaves elements in i
and j
.
Iterate iterable
with a particular value inserted between each element.
Iterate iterable
with a particular value created by a function inserted
between each element.
Creates a new iterator that infinitely applies function to value and yields results.
Combine all iterator elements into one String, seperated by sep
.
Create an iterator that merges elements of the contained iterators using the ordering function.
Create an iterator that merges elements of the contained iterators.
Return the maximum value of the iterable.
Create an iterator that merges elements in i
and j
.
Return an iterator adaptor that merge-joins items from the two base iterators in ascending order.
Return the minimum value of the iterable.
An iterator adaptor that allows the user to peek at multiple .next()
values without advancing the base iterator.
Converts an iterator of tuples into a tuple of containers.
An iterator that generalizes .zip() and allows running multiple iterators in lockstep.
Partition a sequence using predicate pred
so that elements
that map to true
are placed before elements which map to false
.
A drop-in replacement for std::iter::Peekable
which adds a peek_nth
method allowing the user to peek
at a value several iterations forward
without advancing the base iterator.
“Lift” a function of the values of an iterator so that it can process
an iterator of Result
values instead.
Create an iterator where you can put back a single item
Create an iterator where you can put back multiple values to the front of the iteration.
Return an iterator inside a Rc<RefCell<_>>
wrapper.
Create an iterator that produces n
repetitions of element
.
Iterate iterable
in reverse.
Sort all iterator elements into a new iterator in ascending order.
Creates a new unfold source with the specified closure as the “iterator function” and an initial state to eventually pass to the closure
Iterate i
and j
in lock step.
Iterate i
and j
in lock step.