> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# circleci/rust

Easily test, build, run and validate your Rust applications on CircleCI!


## Commands

### build

Build a Rust crate.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `crate` | string |  | Directory of the create to build. |
| `release` | boolean | false | Whether to build the binary for release or debug. |
| `verbose` | boolean | false | When true does a verbose build, i.e. -vv |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

### cargo-run

Run a cargo package.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `package` | string |  | Package to run. |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

### clippy

Run Clippy against your codebase. Learn more: https://github.com/rust-lang/rust-clippy.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `flags` | string | --all --all-targets | Additional flags to pass along to Clippy. |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

### format

Validate formatting of Rust project.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `nightly-toolchain` | boolean | false | Whether or not to use the nightly toolchain version. |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

### install

Install Rustup, Cargo and Rust. Note: it is best practice to leverage a Docker image with Rust preinstalled for reproducibility and speed.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `version` | string | stable | Version of Rust to install and default to. |

### test

Test a cargo crate or package.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `package` | string |  | Package to test. |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

## Jobs

### lint-test-build

Check linting with Clippy, run any present tests then build the crate.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `cache_version` | string | v1 | Cache version to use - increment this to build a fresh cache. |
| `clippy_arguments` | string |  | Arguments to pass to cargo run clippy. |
| `release` | boolean | false | Whether to build the binary for release or debug. |
| `version` | string | 1.49.0 | Version of Rust executor to utilize. |
| `with_cache` | boolean | true | Whether to restore and save the cache or not - set to no if running multiple commands in one job. |
| `working_directory` | string | ~/project | Path to the directory containing your Cargo.lock file. Not needed if Cargo.lock lives in the root. |

## Executors

### default

Default Rust executor.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `tag` | string | 1.49.0 | Tag of the Rust image to use. |

## Examples

### lint_test_build_for_release

Check linting with Clippy, run any present tests then build the crate.

```yaml
version: '2.1'
orbs:
  rust: circleci/rust@x.y.z
workflows:
  production:
    jobs:
      - rust/lint-test-build:
          release: true
```