# WithCargoExample

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

Configures an example target to run instead of a binary.

## Remarks

Passed to cargo as `--example`. Cargo writes examples to `target/<profile>/examples/`,
and debugging and publishing both follow that layout.

## Definition

```go
func (RustAppResource) WithCargoExample(exampleName string) RustAppResource
```

## Parameters

- `exampleName` (`string`) -- The example name, as declared by a file or directory under `examples/`.

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