18 releases (7 breaking)

Uses new Rust 2021

0.8.0 Jul 20, 2022
0.7.0 May 5, 2022
0.6.0 Mar 18, 2022
0.4.4 Oct 18, 2021
0.1.0 Oct 9, 2020

#93 in Rust patterns

Download history 570/week @ 2022-06-12 717/week @ 2022-06-19 561/week @ 2022-06-26 547/week @ 2022-07-03 586/week @ 2022-07-10 462/week @ 2022-07-17 643/week @ 2022-07-24 350/week @ 2022-07-31 568/week @ 2022-08-07 446/week @ 2022-08-14 196/week @ 2022-08-21 242/week @ 2022-08-28 465/week @ 2022-09-04 346/week @ 2022-09-11 167/week @ 2022-09-18 293/week @ 2022-09-25

1,298 downloads per month
Used in 5 crates

MIT/Apache

115KB
2K SLoC

Gazebo - a library of Rust utilities

Support Ukraine GitHub link crates.io version docs.rs availability Build status

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 provides Vec::map which is equivalent to iter().map(f).collect::<Vec<_>>(), and str::split1 like split but which only splits once. We hope some of these functions one day make it into the Rust standard library.
  • gazebo::dupe provides the trait Dupe with the member dupe, all of which are exactly like Clone. The difference is that Dupe should not be implemented for types that reallocate or have expensive clone operations - e.g. there is Dupe for Arc and usize, but not for String and Vec. By using dupe it is easy to focus on the clone calls (which should be rare) and ignore things whose cost is minimal.
  • gazebo::cell::ARef provides a type which is either a Ref<T> or a direct reference &T, with operations that make it look like Ref -- allowing you to uniformly convert a reference into something like a Ref.
  • gazebo::any::AnyLifetime provides a trait like Any, 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 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:

Making a release

  1. Check the GitHub Actions are green.
  2. Update CHANGELOG.md with the changes since the last release. This link can help (update to compare against the last release).
  3. Update the version numbers of the two Cargo.toml files. Bump them by 0.0.1 if there are no incompatible changes, or 0.1.0 if there are. Bump the dependency in gazebo to point at the latest gazebo_derive version.
  4. Copy the files CHANGELOG.md, the two LICENSE- files and README.md into each gazebo and gazebo_derive subdirectory.
  5. Run cargo publish --allow-dirty --dry-run, then without the --dry-run, first in gazebo_derive and then gazebo directories.
  6. Create a GitHub release with v0.X.Y, using the gazebo version 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.

Dependencies

~220–630KB
~15K SLoC