Crate enso_prelude[][src]

Expand description

This module re-exports a lot of useful stuff. It is not meant to be used by libraries, but it is definitely usefull for bigger projects. It also defines several aliases and utils which may find their place in new libraries in the future.

Re-exports

pub use debug::*;
pub use paste;
pub use weak_table;

Modules

Definition of AtLeastOneOfTwo.

Utilities for formatting and printing Strings.

Composable external iteration.

Basic functions for dealing with memory.

A class for monoids (types with an associative binary operation that has an identity) with various general-purpose instances.

This file contains an implementation of Vec that can’t be empty.

In mathematics, a semigroup is an algebraic structure consisting of a set together with an associative binary operation. A semigroup generalizes a monoid in that there might not exist an identity element. It also (originally) generalized a group (a monoid with all inverses) to a type where every element did not have to have an inverse, thus the name semigroup.

Serde reexports for the code generated by declarative macros.

A dynamically-sized view into a contiguous sequence, [T].

Macros

Special logging macro that prints to the Web Console on wasm targets and stdout otherwise. It is supposed to be used only for development purposes and shouldn’t be present in a production-ready code. Macro follows iformat formatting convention.

Derive macro generating an impl of the trait Debug.

Special logging macro that prints to the Web Console on wasm targets and stdout otherwise. It is supposed to be used only for development purposes and shouldn’t be present in a production-ready code. Macro follows iformat formatting convention.

Derive macro generating an impl of the trait Hash.

Special logging macro that prints to the Web Console on wasm targets and stdout otherwise. It is supposed to be used only for development purposes and shouldn’t be present in a production-ready code. Macro follows iformat formatting convention.

Special logging macro that prints to the Web Console on wasm targets and stdout otherwise. It is supposed to be used only for development purposes and shouldn’t be present in a production-ready code. Macro follows iformat formatting convention.

Special logging macro that prints to the Web Console on wasm targets and stdout otherwise. It is supposed to be used only for development purposes and shouldn’t be present in a production-ready code. Macro follows iformat formatting convention.

Macro for cloning values to close.

Clones all arguments from the first argument list by using CloneRef and defines lambda with arguments from the second argument list (if present). For example, the following usage

Variant of the f macro producing a lambda which drops its first argument.

Variant of the f macro producing a lambda which drops its first and second arguments.

Print an iformat!-ed string to standard error.

Print an iformat!-ed string to standard error, followed by \n.

Creates a String by interpolating inline expressions.

Create a fmt::Arguments value a la format_args! with inlined expressions (using the same syntax as iformat!).

Defines a newtype for ImString.

Allows for nicer definition of impls, similar to what Haskell or Scala does. Reduces the needed boilerplate. For example, the following usage:

Panic with an iformat!-ed message.

Print an iformat!-ed string to standard out.

Print an iformat!-ed string to standard out, followed by \n.

Print an iformat!-ed string to the given buffer.

Print an iformat!-ed string to the given buffer, followed by \n.

A macro for use in situations where the code is unreachable.

Structs

Placeholder type used to represent any value type. It is useful to define type-level relations like defining an unit with any quantity, let it be distance or mass.

A map based on a B-Tree.

A mutable memory location.

A copy-on-write String implementation. It is a newtype wrapper for Cow<'static,str> and provides many useful impls for efficient workflow. Use it whenever you want to store a string but you are not sure if the string will be allocated or not. This way you can store a static slice as long as you can and switch to allocated String on demand.

The default Hasher used by RandomState.

Type level false value.

A hash map implemented with quadratic probing and SIMD lookup.

A hash set implemented as a HashMap where the value is ().

Immutable string implementation with a fast clone implementation.

A zero-overhead newtype which provides immutable access to its content. Of course this does not apply to internal mutability of the wrapped data. A good use case of this structure is when you want to pass an ownership to a structure, allow access all its public fields, but do not allow their modification.

A version of std::vec::Vec that can’t be empty.

Zero-sized type used to mark things that “act like” they own a T.

A (half-open) range bounded inclusively below and exclusively above (start..end).

A range only bounded inclusively below (start..).

An unbounded range (..).

A range bounded inclusively below and above (start..=end).

A range only bounded exclusively above (..end).

A range only bounded inclusively above (..=end).

A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.

Wraps a borrowed reference to a value in a RefCell box. A wrapper type for an immutably borrowed value from a RefCell<T>.

A mutable memory location with dynamically checked borrow rules

A wrapper type for a mutably borrowed value from a RefCell<T>.

A Vec-like container that can store a small number of elements inline.

The Switch type. Read module docs to learn more.

Type level true value.

Weak is a version of Rc that holds a non-owning reference to the managed allocation. The allocation is accessed by calling upgrade on the Weak pointer, which returns an Option<Rc<T>>.

A hash map with weak keys, hashed on key value.

A hash map with weak values.

A wrapper adding a phantom type to a structure.

Enums

A struct similar to Option and Either. It can contain the first value, or the second value, or both of them at the same time.

A clone-on-write smart pointer.

Traits

The addition operator +.

A trait to emulate dynamic typing.

The owned version of a type. It would be super cool if Rust would allow us to automatically implement it for every type: Owned<&T> = T and Owned<T> = T if T was not a reference. Unfortunately, we need to implement it by hand for every type now.

This trait defines a number of combinator-style methods for use with bool values.

Generalization of the Cell::get mechanism. Can be used for anything similar to Cell.

Generalization of modify utilities for structures similar to Cell.

Generalization of the Cell::set mechanism. Can be used for anything similar to Cell.

Clone for internal-mutable structures. This trait can be implemented only if mutating one structure will be reflected in all of its clones. Please note that it does not mean that all the fields needs to provide internal mutability as well. For example, a structure can remember it’s creation time and store it as f32. As long as it cannot be mutated, the structure can implement CloneRef. In order to guide the auto-deriving mechanism, it is advised to wrap all immutable fields in the Immutable newtype.

Trait for types that can be internally cloned using CloneRef, like Option<&T>.

Unwrapping utility for wrapped types.

? formatting.

Used for immutable dereferencing operations, like *v.

Used for mutable dereferencing operations, like in *v = 1;.

Format trait for an empty format, {}.

The division operator /.

The Fail trait.

Conversion from an Iterator.

Trait for any type which wraps other type. See docs of Wrapper to learn more.

Type family for structures containing items.

A hashable type.

A trait for hashing an arbitrary stream of bytes.

Used for indexing operations (container[index]) in immutable contexts.

Used for indexing operations (container[index]) in mutable contexts.

An Iterator blanket implementation that provides extra adaptors and methods.

Defines relation between types and values, like between True and true.

Mutable Monoid definition.

The multiplication operator *.

The unary negation operator -.

The base trait for numeric types, covering 0 and 1 values, comparisons, basic numeric operations, and string conversion.

Adds mapping methods to the Option type.

Mutable Semigroup definition. Impls should satisfy the associativity law: x.concat(y.concat(z)) = x.concat(y).concat(z), in symbolic form: x <> (y <> z) = (x <> y) <> z

A utility for easy driving of type-level computations from value level. Often we’ve got some type level relations, like a few singleton types, and for each such type we’ve got an associated value. For example, we can define types Int and Float and associate with them WebGlContext::Int and WebGlContext::Float constants encoded as GlEnum. In order to convert Int or Float to the GlEnum we do not need the instance of the types, only the information what type it was. So we can define:

RangeBounds is implemented by Rust’s built-in range types, produced by range syntax like .., a.., ..b, ..=c, d..e, or f..=g.

Adds utilities to the Result type.

A helper trait used for indexing operations.

Adds methods to the SmallVec type.

Abstraction for a strong reference like Rc or newtypes over it.

The subtraction operator -.

Provides method to, which is just like into but allows fo superfish syntax.

Similar to AsRef but more specific and automatically implemented for every type. Allows for conversion &T to &T (identity) and T to &T for any type T. In contrast, AsRef requires explicit impls, so for example you cannot do let t:&() = ().as_ref()

Simple and safe type conversions that may fail in a controlled way under some circumstances. It is the reciprocal of TryInto.

An attempted conversion that consumes self, which may or may not be expensive.

Like Display trait but for types. However, unlike Display it defaults to impl::any::type_name if not provided with explicit implementation.

Unwraps the content by consuming this value.

Interface for elements that can be stored in weak hash tables.

Interface for elements that can act as keys in weak hash tables.

Mapping methods to the Weak type.

Abstraction for a weak reference like Weak or newtypes over it.

Runs a function on the reference to the content.

Wrapping utility for values.

Functions

Constructor of the Immutable struct.

Provides reference to the content of this value.

Alias for Default::default().

The identity function.

Formats the type for the user-facing output.

Returns the name of a type as a string slice.

Unwrap the content by consuming this value.

Surprisingly useful function. Consider the following code:

Wraps the value and returns the wrapped type.

Type Definitions

Accessor for the wrapped value.

Owned type family.

The following PhantomData implementations allow each argument to be non Sized. Unfortunately, this is not equivalent to PhantomData<(T1,T2,...)>, as tuple requires each arg to implement Sized.

Derive Macros

Derives CloneRef implementation for given type. It performs clone_ref on every member field. The input type must implement Clone and its every field must implement CloneRef.

Trait aliases

Can be transformed from and into.

Trait which enables Sized super-bound on the Content type.

Converts type to its owned version.

This is used to make type inference better at use sites - without it, Rust would force one to write the where clause at every use site.

Like Into but for phantom types.

Alias for for<'t> &'t Self : Into<T>.

Abstraction for any kind of string as an argument. Functions defined as fn test<S:Str>(s: Str) { ... } can be called with String, &String, and &str without requiring caller to know the implementation details. Moreover, the definition can decide if it needs allocation or not. Calling s.as_ref() will never allocate, while s.into() will allocate only when necessary.

Trait for objects which wrap values. Please note that this implements safe wrappers, so the object - value relation must be bijective.