# WithCargoLocked

- Module: [Aspire.Hosting.Rust](/reference/api/go/aspire.hosting.rust.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: [`RustAppResource`](/reference/api/go/aspire.hosting.rust/rustappresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Configures the Rust application to build and run with the exact dependency versions recorded in `Cargo.lock`.

## Remarks

Passed to cargo as `--locked`, which fails the build rather than updating `Cargo.lock`.
Publishing already adds this whenever the crate has a lock file, so a published image cannot silently
pick up dependency versions that were never committed; pass `false` to opt out.
See https://doc.rust-lang.org/cargo/commands/cargo-build.html#manifest-options

## Definition

```go
func (RustAppResource) WithCargoLocked(options ...*WithCargoLockedOptions) RustAppResource
```

## Parameters

- `options` (`...*WithCargoLockedOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithCargoLockedOptions` argument.

- `Locked` (`*bool`) -- `true` to add `--locked`; otherwise `false`.

## Returns

[`RustAppResource`](/reference/api/go/aspire.hosting.rust/rustappresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`RustAppResource`](/reference/api/go/aspire.hosting.rust/rustappresource.md)
