From 34865a9fb53a2b62f9d4478e6128e30b979f6140 Mon Sep 17 00:00:00 2001 From: Dizans <35003291+Dizans@users.noreply.github.com> Date: Fri, 14 Feb 2020 00:34:34 +0800 Subject: [PATCH] chore(docs): Remove unecessary pinning (#263) --- examples/routeguide-tutorial.md | 7 ++----- examples/src/routeguide/server.rs | 14 +++----------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/examples/routeguide-tutorial.md b/examples/routeguide-tutorial.md index e641d27..ffa1bd4 100644 --- a/examples/routeguide-tutorial.md +++ b/examples/routeguide-tutorial.md @@ -447,8 +447,7 @@ async fn record_route( &self, request: Request>, ) -> Result, Status> { - let stream = request.into_inner(); - futures_util::pin_mut!(stream); + let mut stream = request.into_inner(); let mut summary = RouteSummary::default(); let mut last_point = None; @@ -500,11 +499,9 @@ async fn route_chat( request: Request>, ) -> Result, Status> { let mut notes = HashMap::new(); - let stream = request.into_inner(); + let mut stream = request.into_inner(); let output = async_stream::try_stream! { - futures_util::pin_mut!(stream); - while let Some(note) = stream.next().await { let note = note?; diff --git a/examples/src/routeguide/server.rs b/examples/src/routeguide/server.rs index 7760842..4597174 100644 --- a/examples/src/routeguide/server.rs +++ b/examples/src/routeguide/server.rs @@ -68,10 +68,7 @@ impl RouteGuide for RouteGuideService { ) -> Result, Status> { println!("RecordRoute"); - let stream = request.into_inner(); - - // Pin the inbound stream to the stack so that we can call next on it - futures::pin_mut!(stream); + let mut stream = request.into_inner(); let mut summary = RouteSummary::default(); let mut last_point = None; @@ -115,11 +112,9 @@ impl RouteGuide for RouteGuideService { println!("RouteChat"); let mut notes = HashMap::new(); - let stream = request.into_inner(); + let mut stream = request.into_inner(); let output = async_stream::try_stream! { - futures::pin_mut!(stream); - while let Some(note) = stream.next().await { let note = note?; @@ -134,10 +129,7 @@ impl RouteGuide for RouteGuideService { } }; - Ok(Response::new(Box::pin(output) - as Pin< - Box> + Send + Sync + 'static>, - >)) + Ok(Response::new(Box::pin(output) as Self::RouteChatStream)) } }