Skip to content

Commit c036ada

Browse files
taiki-ecramertj
authored andcommitted
Call Pin::set and Pin::as_mut as method
1 parent 98de783 commit c036ada

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

futures-core/src/future/future_obj.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ where
173173
F: Future<Output = T> + 'a
174174
{
175175
fn into_raw(mut self) -> *mut () {
176-
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(Pin::as_mut(&mut self)) };
176+
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(self.as_mut()) };
177177
mut_ref as *mut F as *mut ()
178178
}
179179

@@ -214,7 +214,7 @@ mod if_alloc {
214214
F: Future<Output = T> + 'a
215215
{
216216
fn into_raw(mut self) -> *mut () {
217-
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(Pin::as_mut(&mut self)) };
217+
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(self.as_mut()) };
218218
let ptr = mut_ref as *mut F as *mut ();
219219
mem::forget(self); // Don't drop the box
220220
ptr

futures-core/src/stream/stream_obj.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ mod if_alloc {
215215
where F: Stream<Item = T> + 'a
216216
{
217217
fn into_raw(mut self) -> *mut () {
218-
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(Pin::as_mut(&mut self)) };
218+
let mut_ref: &mut F = unsafe { Pin::get_unchecked_mut(self.as_mut()) };
219219
let ptr = mut_ref as *mut F as *mut ();
220220
mem::forget(self); // Don't drop the box
221221
ptr

futures-util/src/future/fuse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<Fut: Future> Future for Fuse<Fut> {
4242
None => return Poll::Pending,
4343
};
4444

45-
Pin::set(&mut self.as_mut().future(), None);
45+
self.as_mut().future().set(None);
4646
Poll::Ready(v)
4747
}
4848
}

futures-util/src/future/into_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<Fut: Future> Stream for IntoStream<Fut> {
3535
None => return Poll::Ready(None),
3636
};
3737

38-
Pin::set(&mut self.as_mut().future(), None);
38+
self.as_mut().future().set(None);
3939
Poll::Ready(Some(v))
4040
}
4141
}

futures-util/src/future/maybe_done.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<Fut: Future> Future for MaybeDone<Fut> {
106106
MaybeDone::Gone => panic!("MaybeDone polled after value taken"),
107107
}
108108
};
109-
Pin::set(&mut self, MaybeDone::Done(res));
109+
self.set(MaybeDone::Done(res));
110110
Poll::Ready(())
111111
}
112112
}

futures-util/src/sink/with_flat_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898
};
9999
}
100100
}
101-
Pin::set(&mut stream, None);
101+
stream.set(None);
102102
Poll::Ready(Ok(()))
103103
}
104104
}

futures-util/src/stream/for_each.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<St, Fut, F> Future for ForEach<St, Fut, F>
5555
if let Some(future) = self.as_mut().future().as_pin_mut() {
5656
ready!(future.poll(cx));
5757
}
58-
self.as_mut().future().as_mut().set(None);
58+
self.as_mut().future().set(None);
5959

6060
match ready!(self.as_mut().stream().poll_next(cx)) {
6161
Some(e) => {

futures-util/src/stream/unfold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<T, F, Fut, It> Stream for Unfold<T, F, Fut>
9393
) -> Poll<Option<It>> {
9494
if let Some(state) = self.as_mut().state().take() {
9595
let fut = (self.as_mut().f())(state);
96-
Pin::set(&mut self.as_mut().fut(), Some(fut));
96+
self.as_mut().fut().set(Some(fut));
9797
}
9898

9999
let step = ready!(self.as_mut().fut().as_pin_mut().unwrap().poll(cx));

futures-util/src/try_future/flatten_sink.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
Waiting(f) => try_ready!(f.try_poll(cx)),
5656
Closed => panic!("poll_ready called after eof"),
5757
};
58-
Pin::set(&mut self.as_mut(), FlattenSink(Ready(resolved_stream)));
58+
self.set(FlattenSink(Ready(resolved_stream)));
5959
if let Ready(resolved_stream) = self.project_pin() {
6060
resolved_stream.poll_ready(cx)
6161
} else {
@@ -95,7 +95,7 @@ where
9595
Waiting(_) | Closed => Poll::Ready(Ok(())),
9696
};
9797
if res.is_ready() {
98-
Pin::set(&mut self, FlattenSink(Closed));
98+
self.set(FlattenSink(Closed));
9999
}
100100
res
101101
}

futures-util/src/try_stream/try_for_each.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ impl<St, Fut, F> Future for TryForEach<St, Fut, F>
4545
if let Some(future) = self.as_mut().future().as_pin_mut() {
4646
try_ready!(future.try_poll(cx));
4747
}
48-
Pin::set(&mut self.as_mut().future(), None);
48+
self.as_mut().future().set(None);
4949

5050
match ready!(self.as_mut().stream().try_poll_next(cx)) {
5151
Some(Ok(e)) => {
5252
let future = (self.as_mut().f())(e);
53-
Pin::set(&mut self.as_mut().future(), Some(future));
53+
self.as_mut().future().set(Some(future));
5454
}
5555
Some(Err(e)) => return Poll::Ready(Err(e)),
5656
None => return Poll::Ready(Ok(())),

0 commit comments

Comments
 (0)