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::map
which is equivalent toiter().map(f).collect::<Vec<_>>()
, andstr::split1
likesplit
but which only splits once. We hope some of these functions one day make it into the Rust standard library.gazebo::dupe
provides the traitDupe
with the memberdupe
, all of which are exactly likeClone
. The difference is thatDupe
should not be implemented for types that reallocate or have expensiveclone
operations - e.g. there isDupe
forArc
andusize
, but not forString
andVec
. By usingdupe
it is easy to focus on theclone
calls (which should be rare) and ignore things whose cost is minimal.gazebo::cell::ARef
provides 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
.gazebo::any::AnyLifetime
provides a trait likeAny
, but which does not require'static
lifetimes, at the cost of more boilerplate.
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 installed with the standard cargo install
pattern. The two relevant directories 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.
License
Gazebo is both MIT and Apache License, Version 2.0 licensed, as found in the LICENSE-MIT and LICENSE-APACHE files.