Expand description
§Overview
⚠️ important This is an internal crate and is not intended for public use.
Internal crate for the MERC toolset that provides utility types and functions for the Merc toolset.
One important utility is the MercError type, which is a common error type used
throughout the MERC toolset. This type provides thin pointers for dyn Error
trait objects, which helps to reduce memory usage and improve performance when
handling errors. Furthermore, it provides a stack trace by default, which can be
very useful for debugging and diagnosing issues.
An important testing function is the random_test function, which can be used
in tests to provide (reproducible) random state. This is useful for testing code
that relies on randomness, as it allows for consistent and repeatable tests.
Finally, it provides a Timing struct that can be used to measure and record
the time taken by various operations in the MERC toolset.
Furthermore, the DumpFiles struct can be used to manage dumping of
intermediate results to files, which can be very useful for debugging failing
tests. It uses an environment variable MERC_DUMP to determine the absolute
path to dump the files.
§Safety
This crate contains no unsafe code. If unsafe code is needed it should be in the
merc_unsafety crate.
§Minimum Supported Rust Version
We do not maintain an official minimum supported rust version (MSRV), and it may be upgraded at any time when necessary.
§License
All MERC crates are licensed under the BSL-1.0 license. See the LICENSE file in the repository root for more information.
Macros§
- cast
- A macro to return the pat type of an enum class target, and panics otherwise.
- debug_
trace - debug_
use
Structs§
- Display
Pair - A struct that can be used to pretty print the parse tree obtained from the pest crate.
- Generation
Counter - A counter that keeps track of generational indices. This helps manage generations of indices to detect use-after-free and similar issues.
- Generational
Index - A generational index that stores both an index and a generation counter. The generation is only tracked in debug builds to avoid overhead in release.
- Merc
Error - The Merc error type. This has a blanket
Fromimpl for any type that implements Rust’sError, meaning it can be used as a “catch all” error. Captures a backtrace that can be printed from this object. - NoHasher
- A hasher that directly uses the value provided to write_u64 as the hash
- NoHasher
Builder - A builder for NoHasher. Starts with a hash of 0 and returns whatever value is passed to write_u64
- TagIndex
- An index is an index that can only be compared with equivalent tags. Note that the constructor does not requires us to provide a tag, and as such anyone can make a tagged index. It is not a proof of a valid index. This could be extended in the future.
- Timing
- A timing object to measure the time of different parts of the program. This is useful for debugging and profiling.
Traits§
- Merc
Index - A trait for index types.
Functions§
- is_
valid_ permutation - Returns true iff the given permutation is a bijective mapping within the 0..max range.
- random_
test - Constructs a random number generator that should be used in random tests. Prints its seed to the console for reproducibility.
- random_
test_ threads - test_
logger - Constructs a logger for tests. This logger will not print anything to the console, but will instead write to a buffer.
- test_
threads
Type Aliases§
- Phantom
Unsend - Indicates that a type is !Send
- Phantom
Unsync - Indicates that a type is !Sync