# RustAppResource.WithCargoLocked

- Module: [Aspire.Hosting.Rust](/reference/api/go/aspire.hosting.rust.md)
- Defined on: [RustAppResource](/reference/api/go/aspire.hosting.rust/rustappresource.md)
- Version: `17.0.0-preview.1.26567.5`
- Kind: `method`

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
type RustAppResource interface {
    // ... omitted for brevity
    WithCargoLocked(options ...*WithCargoLockedOptions) RustAppResource
}
```

## Signature

```go
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()`.

## Defined on

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