└── README.md
/README.md:
--------------------------------------------------------------------------------
1 | # stdx-dev – the missing development batteries of Rust
2 |
3 | New to Rust development and don't know how to improve your development?
4 | stdx-dev [has the best tools](#about-stdx-dev).
5 |
6 | First, you're going to want to write Rust code using your favorite editor or
7 | IDE, whether that's [emacs], [vi] or [sublime text], [Eclipse] or [IntelliJ],
8 | [Atom] or [VSCode] – or something else entirely. Most tools seem to coalesce
9 | around [racer] and the nascent [RLS] (Rust Language Server). See
10 | [Are we IDE yet?](https://areweideyet.com/) for further information.
11 |
12 | [emacs]: https://github.com/rust-lang/rust-mode
13 | [vi]: https://github.com/rust-lang/rust.vim
14 | [sublime Text]: https://github.com/rust-lang/sublime-rust
15 | [Eclipse]: https://rustdt.github.io/
16 | [IntelliJ]: https://plugins.jetbrains.com/idea/plugin/8182-rust
17 | [Atom]: https://github.com/vertexclique/tokamak
18 | [VSCode]: https://github.com/saviorisdead/RustyCode
19 | [racer]: https://github.com/phildawes/racer
20 | [RLS]: https://github.com/jonathandturner/rls
21 |
22 | ### A Note About Nightly
23 |
24 | Some tools require a nightly Rust compiler to work. This is usually not a
25 | problem, because it's easy enough to run different Rust versions side by side
26 | thanks to [rustup], and most of those tools are only needed while developing
27 | software and either don't factor into or can easily be removed from the final
28 | build. Nevertheless, not everyone wants to maintain a nightly Rust version for
29 | tooling, so we'll mark the respective crates with a ⚠ nightly only
30 | label.
31 |
32 | If you want to have a nightly version, and already have rustup, just type
33 | `rustup install nightly` into your console. To update to the newest version,
34 | use `rustup update nightly`.
35 |
36 | [rustup]: https://rustup.rs
37 |
38 | With that out of the way, here are the goods:
39 |
40 | |feature |crate |
41 | |------------------------|-------------------------|
42 | |code style / correctness|[clippy](#clippy) |
43 | |formatting |[rustfmt](#rustfmt) |
44 | |random testing |[quickcheck](#quickcheck)|
45 | |benchmarks |[bencher](#bencher) |
46 | |profiling |[flame](#flame) |
47 | |dependency management |[cargo-edit](#cargo-edit)|
48 | |dependency management |[cargo-outdated](#cargo-outdated)|
49 | |dependency author listing|[cargo-authors](#cargo-authors)|
50 |
51 | # Clippy
52 |
53 | [Crate](https://crates.io/crates/clippy) |
54 | [Repository](https://github.com/Manishearth/rust-clippy) |
55 | [Docs](https://github.com/Manishearth/rust-clippy/wiki) |
56 | [MPL-2.0] | ⚠ nightly only
57 |
58 | More than 180 lints (at the time of this writing) catch bugs and unfortunate
59 | patterns and give helpful suggestions.
60 |
61 | Install and run clippy with:
62 |
63 | ```sh
64 | cargo +nightly install clippy # install clippy, add "-f" to upgrade existing
65 | cargo +nightly clippy # runs clippy on the current project
66 | ```
67 |
68 | This will likely give you a list of warnings and suggestions. While there
69 | remain some false positives (and negatives), the overall quality is quite good,
70 | and having worked extensively with clippy, I can attest that it sharpens the
71 | newcomer's intuition about what rustic code makes.
72 |
73 | Many IDEs can use clippy within their workflow. Also there's an experimental
74 | [rustfix](https://github.com/killercup/rustfix) tool to auto-apply some of the
75 | suggestions (Warning: Will eat your code).
76 |
77 | # RustFMT
78 |
79 | [Crate](https://crates.io/crates/rustfmt) |
80 | [Repository](https://github.com/rust-lang-nursery/rustfmt) |
81 | [Docs](https://github.com/rust-lang-nursery/rustfmt/blob/master/README.md) |
82 | [MIT] / [Apache-2.0]
83 |
84 | This program will format your code according to some "default" style. It is
85 | highly configurable and will only occasionally eat your laundry.
86 |
87 | Install with `cargo install rustfmt` (add `-f` to update an existing
88 | installation) and run with `cargo fmt` for a whole project or `rustfmt `
89 | to format a single file. There are multiple modes of operation, e.g. output as
90 | diff. Check out the documentation for further assistance.
91 |
92 | # Quickcheck
93 |
94 | [Crate](https://crates.io/crates/quickcheck) |
95 | [Repository](https://github.com/burntsushi/quickcheck) |
96 | [Docs](http://burntsushi.net/rustdoc/quickcheck/) |
97 | [MIT] / [Unlicense]
98 |
99 | This is a crate you can use to generate a series of random inputs for your
100 | tests and *reduce* the input in case of test failure.
101 |
102 | If you have [cargo-edit], you can type `cargo add --dev quickcheck` into a
103 | command line in your crate root. Otherwise, add the following to your
104 | `Cargo.toml` manually:
105 |
106 | ```toml
107 | [dev-dependencies]
108 | quickcheck = "0.4"
109 | ```
110 |
111 | Now you can use quickcheck in your tests! The easiest way is:
112 |
113 | ```rust
114 | #[macro_use] extern crate quickcheck;
115 |
116 | quickcheck! {
117 | // any predicate of any type that has an `Arbitrary` implementation
118 | // most default types already have one
119 | fn check_it(a: usize, b: usize) -> bool {
120 | a == b || a != b
121 | }
122 | }
123 | ```
124 |
125 | # Bencher
126 |
127 | [Crate](https://crates.io/crates/bencher) |
128 | [Repository](https://github.com/bluss/bencher) |
129 | [Docs](https://docs.rs/bencher) |
130 | [MIT] / [Apache-2.0]
131 |
132 | Rust has an internal benchmarking tool, but it's only available on nightly
133 | behind a feature gate. This package makes benchmarks available on stable.
134 |
135 | You'll need the following incantations in your `Cargo.toml`:
136 |
137 | ```toml
138 | [dev-dependencies]
139 | bencher = "0.1"
140 |
141 | # and for each file:
142 | [[bench]]
143 | name = "bench_something"
144 | harness = false
145 | ```
146 |
147 | Now we can add `src/bench_something.rs`:
148 |
149 | ```Rust
150 | #[macro_use] extern crate bencher;
151 |
152 | fn bench_mul(b: &mut bencher::Bencher) {
153 | let i = 1;
154 | b.iter(|| i * i);
155 | }
156 |
157 | // set up the benchmarks group
158 | benchmark_group!(bench, bench_mul); // <- can add more benchmarks here
159 | // and run it
160 | benchmark_main!(bench);
161 | ```
162 |
163 | This can be run with the usual `cargo bench`.
164 |
165 | # Flame
166 |
167 | [Crate](https://crates.io/crates/flame) |
168 | [Repository](https://github.com/TyOverby/flame) |
169 | [Docs](https://docs.rs/flame) |
170 | [MIT] / [Apache-2.0]
171 |
172 | Flame is a library that allows you to stopwatch your code and see the result
173 | rendered as a flame graph. There is also the (⚠ nightly only)
174 | [flamer] plugin that lets you annotate your crates/modules/items to insert
175 | flame trace points.
176 |
177 | [flamer]: https://github.com/llogiq/flamer
178 |
179 | Code augmented by `flame` can look like the following:
180 |
181 | ```Rust
182 | extern crate flame;
183 |
184 | fn foo() {
185 | flame::start("foo");
186 | let result = ...;
187 | flame::end("foo");
188 | return result;
189 | }
190 |
191 | fn main() {
192 | flame::start("main");
193 | let foo = foo();
194 | ...
195 | flame::end("main");
196 | }
197 | ```
198 |
199 | The resulting flame graph can look like this:
200 |
201 | https://raw.githubusercontent.com/TyOverby/flame/master/resources/screenshot.png
202 |
203 | # cargo-edit
204 |
205 | [Crate](https://crates.io/crates/cargo-edit) |
206 | [Repository](https://github.com/killercup/cargo-edit) |
207 | [Docs](https://github.com/killercup/cargo-edit/blob/master/README.md) |
208 | [MIT] / [Apache-2.0]
209 |
210 | This crate gives you the `cargo add`, `cargo rm` and `cargo list` subcommands,
211 | allowing for easy dependency management from the command line. Refer to the
212 | docs for further information.
213 |
214 | # cargo-outdated
215 |
216 | [Crate](https://crates.io/crates/cargo-outdated) |
217 | [Repository](https://github.com/kbknapp/cargo-outdated) |
218 | [Docs](https://github.com/kbknapp/cargo-outdated/blob/master/README.md) |
219 | [MIT]
220 |
221 | This crate gives you the `cargo outdated` subcommand which displays when
222 | dependencies have newer versions available.
223 |
224 | # cargo-authors
225 |
226 | [Crate](https://crates.io/crates/cargo-authors) |
227 | [Repository](https://github.com/Henning-K/cargo-authors) |
228 | [Docs](https://github.com/Henning-K/cargo-authors/blob/master/README.md) |
229 | [MIT] / [Apache-2.0]
230 |
231 | This crate gives you the `cargo authors` subcommand which lists all the
232 | authors of all the dependencies of the crate in your current working directory.
233 |
234 | ----
235 |
236 | # About stdx-dev
237 |
238 | The [stdx](https://github.com/brson/stdx) curated list of crates has some great
239 | crates that you can build on, but it lacks all kinds of crates that make
240 | *development* with Rust even more awesome.
241 |
242 | So I'm going to try and list them here. If you find any crate I've missed, file
243 | an issue or a PR. Thank you!
244 |
245 | The contents of this repository are licensed under [MIT] / [Apache-2.0], at
246 | your discretion.
247 |
248 | [Apache-2.0]: http://www.apache.org/licenses/LICENSE-2.0
249 | [MIT]: http://opensource.org/licenses/MIT
250 | [MPL-2.0]: https://www.mozilla.org/MPL/2.0/
251 | [Unlicense]: http://unlicense.org/
252 |
--------------------------------------------------------------------------------