# WithCargoArgs

- 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)

Adds command-line arguments to the cargo command used by a Rust application.

## Remarks

Arguments are forwarded to cargo verbatim and are not interpreted. Publishing and debugging work out
which file cargo produces from the `WithCargo*` options alone, so a target selection that has a
dedicated method -- `WithCargoBinTarget`, `WithCargoExample`, `WithCargoPackage`,
`WithCargoProfile`, `WithCargoReleaseBuild` and `WithCargoTarget` -- has to go through
it rather than being passed here.

## Definition

```go
func (RustAppResource) WithCargoArgs(args []string) RustAppResource
```

## Parameters

- `args` (`[]string`) -- The cargo arguments to append before `--`.

## 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)
