Add method for referring to Client's inner type (#302)

This commit is contained in:
bnaecker 2023-01-13 15:08:18 -08:00 committed by GitHub
parent 96af7b5a09
commit 6eaacdfc93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -239,6 +239,17 @@ impl Generator {
let types = self.type_space.to_stream();
// Generate an implementation of a `Self::as_inner` method, if an inner
// type is defined.
let maybe_inner = self.settings.inner_type.as_ref().map(|inner| {
quote! {
/// Return a reference to the inner type stored in `self`.
pub fn inner(&self) -> &#inner {
&self.inner
}
}
});
let inner_property = self.settings.inner_type.as_ref().map(|inner| {
quote! {
pub (crate) inner: #inner,
@ -334,6 +345,8 @@ impl Generator {
pub fn client(&self) -> &reqwest::Client {
&self.client
}
#maybe_inner
}
#operation_code