• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
  • Created almost 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust's missing development batteries

stdx-dev – the missing development batteries of Rust

New to Rust development and don't know how to improve your development? stdx-dev has the best tools.

First, you're going to want to write Rust code using your favorite editor or IDE, whether that's emacs, vi or sublime text, Eclipse or IntelliJ, Atom or VSCode – or something else entirely. Most tools seem to coalesce around racer and the nascent RLS (Rust Language Server). See Are we IDE yet? for further information.

A Note About Nightly

Some tools require a nightly Rust compiler to work. This is usually not a problem, because it's easy enough to run different Rust versions side by side thanks to rustup, and most of those tools are only needed while developing software and either don't factor into or can easily be removed from the final build. Nevertheless, not everyone wants to maintain a nightly Rust version for tooling, so we'll mark the respective crates with a âš  nightly only label.

If you want to have a nightly version, and already have rustup, just type rustup install nightly into your console. To update to the newest version, use rustup update nightly.

With that out of the way, here are the goods:

feature crate
code style / correctness clippy
formatting rustfmt
random testing quickcheck
benchmarks bencher
profiling flame
dependency management cargo-edit
dependency management cargo-outdated
dependency author listing cargo-authors

Clippy

Crate | Repository | Docs | MPL-2.0 | âš  nightly only

More than 180 lints (at the time of this writing) catch bugs and unfortunate patterns and give helpful suggestions.

Install and run clippy with:

cargo +nightly install clippy # install clippy, add "-f" to upgrade existing
cargo +nightly clippy # runs clippy on the current project

This will likely give you a list of warnings and suggestions. While there remain some false positives (and negatives), the overall quality is quite good, and having worked extensively with clippy, I can attest that it sharpens the newcomer's intuition about what rustic code makes.

Many IDEs can use clippy within their workflow. Also there's an experimental rustfix tool to auto-apply some of the suggestions (Warning: Will eat your code).

RustFMT

Crate | Repository | Docs | MIT / Apache-2.0

This program will format your code according to some "default" style. It is highly configurable and will only occasionally eat your laundry.

Install with cargo install rustfmt (add -f to update an existing installation) and run with cargo fmt for a whole project or rustfmt <file> to format a single file. There are multiple modes of operation, e.g. output as diff. Check out the documentation for further assistance.

Quickcheck

Crate | Repository | Docs | MIT / Unlicense

This is a crate you can use to generate a series of random inputs for your tests and reduce the input in case of test failure.

If you have [cargo-edit], you can type cargo add --dev quickcheck into a command line in your crate root. Otherwise, add the following to your Cargo.toml manually:

[dev-dependencies]
quickcheck = "0.4"

Now you can use quickcheck in your tests! The easiest way is:

#[macro_use] extern crate quickcheck;

quickcheck! {
    // any predicate of any type that has an `Arbitrary` implementation
    // most default types already have one
    fn check_it(a: usize, b: usize) -> bool {
        a == b || a != b
    }
}

Bencher

Crate | Repository | Docs | MIT / Apache-2.0

Rust has an internal benchmarking tool, but it's only available on nightly behind a feature gate. This package makes benchmarks available on stable.

You'll need the following incantations in your Cargo.toml:

[dev-dependencies]
bencher = "0.1"

# and for each file:
[[bench]]
name = "bench_something"
harness = false

Now we can add src/bench_something.rs:

#[macro_use] extern crate bencher;

fn bench_mul(b: &mut bencher::Bencher) {
    let i = 1;
    b.iter(|| i * i);
}

// set up the benchmarks group
benchmark_group!(bench, bench_mul); // <- can add more benchmarks here
// and run it
benchmark_main!(bench);

This can be run with the usual cargo bench.

Flame

Crate | Repository | Docs | MIT / Apache-2.0

Flame is a library that allows you to stopwatch your code and see the result rendered as a flame graph. There is also the (âš  nightly only) flamer plugin that lets you annotate your crates/modules/items to insert flame trace points.

Code augmented by flame can look like the following:

extern crate flame;

fn foo() {
   flame::start("foo");
   let result = ...;
   flame::end("foo");
   return result;
}

fn main() {
   flame::start("main");
   let foo = foo();
   ...
   flame::end("main");
}

The resulting flame graph can look like this:

https://raw.githubusercontent.com/TyOverby/flame/master/resources/screenshot.png

cargo-edit

Crate | Repository | Docs | MIT / Apache-2.0

This crate gives you the cargo add, cargo rm and cargo list subcommands, allowing for easy dependency management from the command line. Refer to the docs for further information.

cargo-outdated

Crate | Repository | Docs | MIT

This crate gives you the cargo outdated subcommand which displays when dependencies have newer versions available.

cargo-authors

Crate | Repository | Docs | MIT / Apache-2.0

This crate gives you the cargo authors subcommand which lists all the authors of all the dependencies of the crate in your current working directory.


About stdx-dev

The stdx curated list of crates has some great crates that you can build on, but it lacks all kinds of crates that make development with Rust even more awesome.

So I'm going to try and list them here. If you find any crate I've missed, file an issue or a PR. Thank you!

The contents of this repository are licensed under MIT / Apache-2.0, at your discretion.

More Repositories

1

flame

An intrusive flamegraph profiling tool for rust.
Rust
672
star
2

mutagen

Breaking your Rust code for fun and profit
Rust
621
star
3

flamer

A compiler plugin to insert flame calls
Rust
364
star
4

momo

A Rust proc_macro_attribute to outline conversions from generic functions
Rust
239
star
5

bytecount

Counting occurrences of a given byte or UTF-8 characters in a slice of memory – fast
Rust
214
star
6

metacollect

A lint to collect some crate metadata
Rust
115
star
7

overflower

A Rust compiler plugin and support library to annotate overflow behavior
Rust
103
star
8

compact_arena

A crate with indexed arenas with small memory footprint
Rust
76
star
9

optional

A small crate to provide space-efficient Option<_> replacements
Rust
35
star
10

serdebench

Rust
30
star
11

newlinebench

Rust
21
star
12

partition

partition slices in-place by a predicate
Rust
14
star
13

compressbench

A benchmark of Rust compression libraries
Rust
9
star
14

smallvectune

Rust
9
star
15

llogiq.github.io

My github page
HTML
8
star
16

pathsep

A os agnostic way to get a path separator in macros
Rust
7
star
17

extra_lints

more lints for rust (now subsumed in rust-clippy)
Rust
7
star
18

arraymap

Adds a trait to map functions over arrays
Rust
6
star
19

bsdiff-rs

A Rust BSDiff port
Rust
4
star
20

arraymapbench

A benchmark of various map methods
Rust
2
star
21

twirer

A short program I use to collect and filter the core changes for This Week In Rust
Rust
2
star
22

picnic

Your Picnic Is On Fire!
Rust
1
star
23

openpgp

Rust
1
star
24

rangeset

(WIP) a RangeSet implementation
Rust
1
star
25

typetree

a data structure within Rust's type system
Rust
1
star
26

rust-stockfighter

Simple Rust Wrapper for stockfigher
Rust
1
star
27

ternary

Kleene logic in Rust's type system
Rust
1
star
28

lib_json

Allocationless Json Parsing
Rust
1
star
29

wom

Write-Only Memory for Rust
Rust
1
star