Azure / Azure/typespec-rust

Compilation error: codegen emits the code for optional api version, when it is not

Open
#920 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
7
Forks
11
Avg merge
2d 5h
Merged PRs (30d)
5

Description

This affects `specification/purview/data-plane/datamap`:

```
error[E0277]: the trait bound `std::string::String: AsRef>` is not satisfied
--> spec\datamap\src\generated\clients\data_map_discovery_client.rs:47:53
|
47 | if let Some(api_version) = self.api_version.as_ref() {
| ^^^^^^ the trait `AsRef>` is not implemented for `std::string::String`
|
= help: the following other types implement trait `AsRef`:
`std::string::String` implements `AsRef`
`std::string::String` implements `AsRef`
`std::string::String` implements `AsRef<[u8]>`
`std::string::String` implements `AsRef`
```
when
```rs
...
#[tracing::client]
pub struct DataMapDiscoveryClient {
pub(crate) api_version: String, // <-- declared here
pub(crate) endpoint: Url,
pub(crate) pipeline: Pipeline,
}

impl DataMapDiscoveryClient {
...
#[tracing::function("Customizations.Discovery.autoComplete")]
pub async fn auto_complete(
&self,
body: RequestContent,
options: Option>,
) -> Result> {
let options = options.unwrap_or_default();
let ctx = options.method_options.context.to_borrowed();
let mut url = self.endpoint.clone();
url.append_path("/search/autocomplete");
let mut query_builder = url.query_builder();
if let Some(api_version) = self.api_version.as_ref() { // <--fails here
query_builder.set_pair("api-version", api_version);
}
...

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.