Crate ergo_std

Source
Expand description

ergo_std: items that could be in the standard library.

This is the “core types” library as part of the ergo crates ecosystem. It contains useful types, traits and functions for general purpose programming projects which do not fall into the other ergo crates but which are boons to ergonomics and productivity.

§How to Use

In your Cargo.toml

[dependencies]
ergo_std = "0.1"
serde = "1.0"
serde_derive = "1.0"

You have to put the other crates in your Cargo.toml in order for #[derive(...)] to work correctly.

#[macro_use] extern crate ergo_std;
use ergo_std::*;
fn main() {
    /* Your code goes here */
}

§Exported Items

The following crates and types are exported. See their docs for how to use them.

  • std_prelude: extends rust’s std::prelude with commonly used types. The crate is well documented with justification and usecases for each type.
  • serde: the defacto serialization library of rust. Also imports serde_derive so you can use #[derive(Serialize, Deserialize)].
  • lazy_static!: the lazy_static! macro is the current standard way to create global variables and constants. Warning that they are created lazily (at run time)!
  • itertools: the itertools prelude provides traits that extends rust’s already extensive iterator API.
  • indexmap: indexable and sortable map and set types with similar performance to std types and beter performance when iterating.
  • maplit: provides hashmap!, hashset!, btreemap! and btreeset! macros to compliment rust’s existing vec! macro. These
  • Regex: the regular expression type from the regex crate.

§Special thanks

The crates that are exported are:

  • serde: Serialization framework for Rust
  • std_prelude: prelude that the rust stdlib should have always had
  • lazy_static: A small macro for defining lazy evaluated static variables in Rust.
  • itertools: Extra iterator adaptors, iterator methods, free functions, and macros.
  • indexmap: A hash table with consistent order and fast iteration (previously named ordermap)
  • maplit: Rust container / collection literal macros for HashMap, HashSet, BTreeMap, BTreeSet.
  • regex: An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.

Consider supporting their development individually and starring them on github.

Re-exports§

pub extern crate indexmap;
pub extern crate itertools;
pub extern crate lazy_static;
pub extern crate maplit;
pub extern crate regex;
pub extern crate serde;
pub extern crate serde_derive;
pub extern crate std_prelude;

Modules§

de
Generic data structure deserialization framework.
f32
Constants for the f32 single-precision floating point type.
f64
Constants for the f64 double-precision floating point type.
i8Deprecation planned
Redundant constants module for the i8 primitive type.
i16Deprecation planned
Redundant constants module for the i16 primitive type.
i64Deprecation planned
Redundant constants module for the i64 primitive type.
isizeDeprecation planned
Redundant constants module for the isize primitive type.
map
IndexMap is a hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
ser
Generic data structure serialization framework.
serde_seq
Functions to serialize and deserialize an IndexMap as an ordered sequence.
set
A hash set implemented using IndexMap
str
Utilities for the str primitive type.
u8Deprecation planned
Redundant constants module for the u8 primitive type.
u16Deprecation planned
Redundant constants module for the u16 primitive type.
u64Deprecation planned
Redundant constants module for the u64 primitive type.
usizeDeprecation planned
Redundant constants module for the usize primitive type.

Macros§

btreemap
Create a BTreeMap from a list of key-value pairs
btreeset
Create a BTreeSet from a list of elements.
convert_args
Macro that converts the keys or key-value pairs passed to another maplit macro. The default conversion is to use the Into trait, if no custom conversion is passed.
forward_to_deserialize_any
Helper macro when implementing the Deserializer part of a new data format for Serde.
hashmap
Create a HashMap from a list of key-value pairs
hashset
Create a HashSet from a list of elements.
indexmap
Create an IndexMap from a list of key-value pairs
indexset
Create an IndexSet from a list of values
lazy_static

Structs§

Arc
A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
AtomicBool
A boolean type which can be safely shared between threads.
AtomicIsize
An integer type which can be safely shared between threads.
AtomicUsize
An integer type which can be safely shared between threads.
BTreeMap
An ordered map based on a B-Tree.
BufReader
The BufReader<R> struct adds buffering to any reader.
BufWriter
Wraps a writer and buffers its output.
Duration
A Duration type to represent a span of time, typically used for system timeouts.
File
An object providing access to an open file on the filesystem.
HashMap
A hash map implemented with quadratic probing and SIMD lookup.
HashSet
A hash set implemented as a HashMap where the value is ().
IndexMap
A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
IndexSet
A hash set where the iteration order of the values is independent of their hash values.
Mutex
A mutual exclusion primitive useful for protecting shared data
OpenOptions
Options and flags which can be used to configure how a file is opened.
OsString
A type that can represent owned, mutable platform-native strings, but is cheaply inter-convertible with Rust strings.
Path
A slice of a path (akin to str).
PathBuf
An owned, mutable path (akin to String).
Rc
A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.
ReadDir
Iterator over the entries in a directory.
Regex
A compiled regular expression for matching Unicode strings.

Enums§

AtomicOrdering
Atomic memory orderings
Cow
A clone-on-write smart pointer.
Ordering
An Ordering is the result of a comparison between two values.
SeekFrom
Enumeration of possible methods to seek within an I/O object.

Constants§

ATOMIC_USIZE_INITDeprecated
An AtomicUsize initialized to 0.

Traits§

AsciiExtDeprecated
Extension methods for ASCII-subset only operations.
Borrow
A trait for borrowing data.
BufRead
A BufRead is a type of Reader which has an internal buffer, allowing it to perform extra ways of reading.
Debug
? formatting.
Deref
Used for immutable dereferencing operations, like *v.
DerefMut
Used for mutable dereferencing operations, like in *v = 1;.
Deserialize
A data structure that can be deserialized from any data format supported by Serde.
Deserializer
A data format that can deserialize any data structure supported by Serde.
Equivalent
Key equivalence trait.
FmtWrite
A trait for writing or formatting into Unicode-accepting buffers or streams.
FromIterator
Conversion from an Iterator.
FromStr
Parse a value from a string
Hash
A hashable type.
Hasher
A trait for hashing an arbitrary stream of bytes.
IoWrite
A trait for objects which are byte-oriented sinks.
Itertools
The trait Itertools: extra iterator adaptors and methods for iterators.
LazyStatic
Support trait for enabling a few common operation on lazy static values.
Ord
Trait for types that form a total order.
PartialOrd
Trait for types that form a partial order.
Read
The Read trait allows for reading bytes from a source.
Seek
The Seek trait provides a cursor which can be moved within a stream of bytes.
Serialize
A data structure that can be serialized into any data format supported by Serde.
Serializer
A data format that can serialize any data structure supported by Serde.
__Deref
Used for immutable dereferencing operations, like *v.

Functions§

initialize
Takes a shared reference to a lazy static and initializes it if it has not been already.
size_of
Returns the size of a type in bytes.
size_of_val
Returns the size of the pointed-to value in bytes.
sleep
Puts the current thread to sleep for at least the specified amount of time.
spawn
Spawns a new thread, returning a JoinHandle for it.

Derive Macros§

Debug
Derive macro generating an impl of the trait Debug.
Deserialize
Hash
Derive macro generating an impl of the trait Hash.
Ord
Derive macro generating an impl of the trait Ord. The behavior of this macro is described in detail here.
PartialOrd
Derive macro generating an impl of the trait PartialOrd. The behavior of this macro is described in detail here.
Serialize