fix(build): Remove ambiguity in service method call (#327)
When calling methods on Arc<MyService> where the method is also defined on Arc (e.g. drop and clone), calling inner.#method_ident(request) will actually attempt to call the Arc method instead of the method on the service, resulting in a compile error. This change removes the ambiguity by dereferencing the inner Arc.
This commit is contained in:
@@ -273,7 +273,7 @@ fn generate_unary<T: Method>(
|
||||
fn call(&mut self, request: tonic::Request<#request>) -> Self::Future {
|
||||
let inner = self.0.clone();
|
||||
let fut = async move {
|
||||
inner.#method_ident(request).await
|
||||
(*inner).#method_ident(request).await
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
@@ -326,7 +326,7 @@ fn generate_server_streaming<T: Method>(
|
||||
fn call(&mut self, request: tonic::Request<#request>) -> Self::Future {
|
||||
let inner = self.0.clone();
|
||||
let fut = async move {
|
||||
inner.#method_ident(request).await
|
||||
(*inner).#method_ident(request).await
|
||||
|
||||
};
|
||||
Box::pin(fut)
|
||||
@@ -377,7 +377,7 @@ fn generate_client_streaming<T: Method>(
|
||||
fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future {
|
||||
let inner = self.0.clone();
|
||||
let fut = async move {
|
||||
inner.#method_ident(request).await
|
||||
(*inner).#method_ident(request).await
|
||||
|
||||
};
|
||||
Box::pin(fut)
|
||||
@@ -432,7 +432,7 @@ fn generate_streaming<T: Method>(
|
||||
fn call(&mut self, request: tonic::Request<tonic::Streaming<#request>>) -> Self::Future {
|
||||
let inner = self.0.clone();
|
||||
let fut = async move {
|
||||
inner.#method_ident(request).await
|
||||
(*inner).#method_ident(request).await
|
||||
};
|
||||
Box::pin(fut)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user