gazebo
gazebo copied to clipboard
A Rust library containing a collection of small well-tested primitives.
Gazebo - a library of Rust utilities
This library contains a collection of well-tested utilities. Most modules stand alone, but taking a few representative examples:
gazebo::prelude::*is intended to be imported as such, and provides extension traits to common types. For example, it providesVec::mapwhich is equivalent toiter().map(f).collect::<Vec<_>>(), andstr::split1likesplitbut which only splits once. We hope some of these functions one day make it into the Rust standard library.gazebo::dupeprovides the traitDupewith the memberdupe, all of which are exactly likeClone. The difference is thatDupeshould not be implemented for types that reallocate or have expensivecloneoperations - e.g. there isDupeforArcandusize, but not forStringandVec. By usingdupeit is easy to focus on theclonecalls (which should be rare) and ignore things whose cost is minimal.gazebo::cell::ARefprovides a type which is either aRef<T>or a direct reference&T, with operations that make it look likeRef-- allowing you to uniformly convert a reference into something like aRef.
The functionality provided by Gazebo is not stable, and continues to evolve with both additions (as we find new useful features) and removals (as we find better patterns or libraries encapsulating the ideas better). While the code varies in usefulness and design quality, it is all well tested and documented.
Using Gazebo
Gazebo can be depended upon by adding gazebo to your [dependencies], using
the standard
Cargo patterns.
The two interesting directories in this repo are gazebo (which contains the
source to Gazebo itself) and gazebo_derive (which contains support for
#[derive(Dupe)] and other Gazebo traits). Usually you will directly import
gazebo, but gazebo_derive is a required transitive dependency if you are
sourcing the library from GitHub.
Learn More
You can learn more about Gazebo in this introductory video, or from the following blog posts:
- Rust Nibbles - Gazebo: Prelude
- Rust Nibbles - Gazebo: Dupe
- Rust Nibbles - Gazebo: Variants
- Rust Nibbles - Gazebo: AnyLifetime
- Rust Nibbles - Gazebo: Comparisons
- Rust Nibbles - Gazebo: Casts and Transmute
- Rust Nibbles - Gazebo: The rest of the tent
Making a release
- Check the GitHub Actions are green.
- Update
CHANGELOG.mdwith the changes since the last release. This link can help (update to compare against the last release). - Update the version numbers of the two
Cargo.tomlfiles. Bump them by 0.0.1 if there are no incompatible changes, or 0.1.0 if there are. Bump the dependency ingazeboto point at the latestgazebo_deriveversion. - Copy the files
CHANGELOG.md, the twoLICENSE-files andREADME.mdinto eachgazeboandgazebo_derivesubdirectory. - Run
cargo publish --allow-dirty --dry-run, then without the--dry-run, first ingazebo_deriveand thengazebodirectories. - Create a
GitHub release
with
v0.X.Y, using thegazeboversion as the name.
License
Gazebo is both MIT and Apache License, Version 2.0 licensed, as found in the LICENSE-MIT and LICENSE-APACHE files.