# RustAppResource.WithCargoExample

- 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.26565.2`
- Kind: `method`

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
type RustAppResource interface {
    // ... omitted for brevity
    WithCargoExample(exampleName string) RustAppResource
}
```

## Signature

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

## Defined on

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