I am not sure if this is possible or not but I spent some time trying to figure out where my bounds were not satisfied. I wonder if the compiler can already do this matching.
The code is a bit complex to get it separated but here is the bit that matters
let octocrabi = octocrab::OctocrabBuilder::new_empty()
.with_service(client)
.with_layer(&BaseUriLayer::new(http::Uri::from_static(
"https://api.github.com",
)))
.with_auth(auth)
.build()?;
This code fails to compile because build
is only available when auth
is AuthState
. That's cool, except that the message the compiler outputs is the following
error[E0599]: no method named `build` found for struct `OctocrabBuilder<BaseUri<TReq>, NoConfig, Auth, LayerReady>` in the current scope
--> src/lib.rs:189:40
|
189 | .build()?;
| ^^^^^ method not found in `OctocrabBuilder<BaseUri<TReq>, NoConfig, Auth, LayerReady>`
|
= note: the method was found for
- `OctocrabBuilder<Svc, NoConfig, AuthState, LayerState>`
Now you might looking at this and say that the type AuthState
is expected and I am providing Auth
but this is only obviously after the fact. During the debugging process, you are wondering whether it's LayerState
, or Svc
. It's not clear from the error message which one is responsible for this.
Any ways to make this clearer?