Skip to content

Commit db79aef

Browse files
taiki-ecramertj
authored andcommitted
Call Pin::get_* as method
1 parent 93223f5 commit db79aef

File tree

18 files changed

+37
-37
lines changed

18 files changed

+37
-37
lines changed

futures-core/src/stream/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ where
7979
self: Pin<&mut Self>,
8080
cx: &mut Context<'_>,
8181
) -> Poll<Option<Self::Item>> {
82-
Pin::get_mut(self).as_mut().poll_next(cx)
82+
self.get_mut().as_mut().poll_next(cx)
8383
}
8484
}
8585

futures-io/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ mod if_std {
376376
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8])
377377
-> Poll<Result<usize>>
378378
{
379-
Pin::get_mut(self).as_mut().poll_read(cx, buf)
379+
self.get_mut().as_mut().poll_read(cx, buf)
380380
}
381381

382382
fn poll_read_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>])
383383
-> Poll<Result<usize>>
384384
{
385-
Pin::get_mut(self).as_mut().poll_read_vectored(cx, bufs)
385+
self.get_mut().as_mut().poll_read_vectored(cx, bufs)
386386
}
387387
}
388388

@@ -464,21 +464,21 @@ mod if_std {
464464
fn poll_write(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8])
465465
-> Poll<Result<usize>>
466466
{
467-
Pin::get_mut(self).as_mut().poll_write(cx, buf)
467+
self.get_mut().as_mut().poll_write(cx, buf)
468468
}
469469

470470
fn poll_write_vectored(self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>])
471471
-> Poll<Result<usize>>
472472
{
473-
Pin::get_mut(self).as_mut().poll_write_vectored(cx, bufs)
473+
self.get_mut().as_mut().poll_write_vectored(cx, bufs)
474474
}
475475

476476
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
477-
Pin::get_mut(self).as_mut().poll_flush(cx)
477+
self.get_mut().as_mut().poll_flush(cx)
478478
}
479479

480480
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
481-
Pin::get_mut(self).as_mut().poll_close(cx)
481+
self.get_mut().as_mut().poll_close(cx)
482482
}
483483
}
484484

futures-sink/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ where
139139
type SinkError = <P::Target as Sink<Item>>::SinkError;
140140

141141
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
142-
Pin::get_mut(self).as_mut().poll_ready(cx)
142+
self.get_mut().as_mut().poll_ready(cx)
143143
}
144144

145145
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
146-
Pin::get_mut(self).as_mut().start_send(item)
146+
self.get_mut().as_mut().start_send(item)
147147
}
148148

149149
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
150-
Pin::get_mut(self).as_mut().poll_flush(cx)
150+
self.get_mut().as_mut().poll_flush(cx)
151151
}
152152

153153
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
154-
Pin::get_mut(self).as_mut().poll_close(cx)
154+
self.get_mut().as_mut().poll_close(cx)
155155
}
156156
}
157157

@@ -176,7 +176,7 @@ mod if_alloc {
176176

177177
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError> {
178178
// TODO: impl<T> Unpin for Vec<T> {}
179-
unsafe { Pin::get_unchecked_mut(self) }.push(item);
179+
unsafe { self.get_unchecked_mut() }.push(item);
180180
Ok(())
181181
}
182182

@@ -198,7 +198,7 @@ mod if_alloc {
198198

199199
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError> {
200200
// TODO: impl<T> Unpin for Vec<T> {}
201-
unsafe { Pin::get_unchecked_mut(self) }.push_back(item);
201+
unsafe { self.get_unchecked_mut() }.push_back(item);
202202
Ok(())
203203
}
204204

futures-util/src/future/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<Fut1, Fut2, Data> Chain<Fut1, Fut2, Data>
3434
let mut f = Some(f);
3535

3636
// Safe to call `get_unchecked_mut` because we won't move the futures.
37-
let this = unsafe { Pin::get_unchecked_mut(self) };
37+
let this = unsafe { self.get_unchecked_mut() };
3838

3939
loop {
4040
let (output, data) = match this {

futures-util/src/future/either.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ where
5757

5858
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<A::Output> {
5959
unsafe {
60-
match Pin::get_unchecked_mut(self) {
60+
match self.get_unchecked_mut() {
6161
Either::Left(a) => Pin::new_unchecked(a).poll(cx),
6262
Either::Right(b) => Pin::new_unchecked(b).poll(cx),
6363
}
@@ -74,7 +74,7 @@ where
7474

7575
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<A::Item>> {
7676
unsafe {
77-
match Pin::get_unchecked_mut(self) {
77+
match self.get_unchecked_mut() {
7878
Either::Left(a) => Pin::new_unchecked(a).poll_next(cx),
7979
Either::Right(b) => Pin::new_unchecked(b).poll_next(cx),
8080
}
@@ -91,7 +91,7 @@ where
9191

9292
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
9393
unsafe {
94-
match Pin::get_unchecked_mut(self) {
94+
match self.get_unchecked_mut() {
9595
Either::Left(x) => Pin::new_unchecked(x).poll_ready(cx),
9696
Either::Right(x) => Pin::new_unchecked(x).poll_ready(cx),
9797
}
@@ -100,7 +100,7 @@ where
100100

101101
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
102102
unsafe {
103-
match Pin::get_unchecked_mut(self) {
103+
match self.get_unchecked_mut() {
104104
Either::Left(x) => Pin::new_unchecked(x).start_send(item),
105105
Either::Right(x) => Pin::new_unchecked(x).start_send(item),
106106
}
@@ -109,7 +109,7 @@ where
109109

110110
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
111111
unsafe {
112-
match Pin::get_unchecked_mut(self) {
112+
match self.get_unchecked_mut() {
113113
Either::Left(x) => Pin::new_unchecked(x).poll_flush(cx),
114114
Either::Right(x) => Pin::new_unchecked(x).poll_flush(cx),
115115
}
@@ -118,7 +118,7 @@ where
118118

119119
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
120120
unsafe {
121-
match Pin::get_unchecked_mut(self) {
121+
match self.get_unchecked_mut() {
122122
Either::Left(x) => Pin::new_unchecked(x).poll_close(cx),
123123
Either::Right(x) => Pin::new_unchecked(x).poll_close(cx),
124124
}

futures-util/src/future/flatten_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum State<Fut, St> {
4343
impl<Fut, St> State<Fut, St> {
4444
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> State<Pin<&'a mut Fut>, Pin<&'a mut St>> {
4545
// safety: data is never moved via the resulting &mut reference
46-
match unsafe { Pin::get_unchecked_mut(self) } {
46+
match unsafe { self.get_unchecked_mut() } {
4747
// safety: the future we're re-pinning here will never be moved;
4848
// it will just be polled, then dropped in place
4949
State::Future(f) => State::Future(unsafe { Pin::new_unchecked(f) }),

futures-util/src/future/maybe_done.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<Fut: Future> MaybeDone<Fut> {
5252
#[inline]
5353
pub fn output_mut<'a>(self: Pin<&'a mut Self>) -> Option<&'a mut Fut::Output> {
5454
unsafe {
55-
let this = Pin::get_unchecked_mut(self);
55+
let this = self.get_unchecked_mut();
5656
match this {
5757
MaybeDone::Done(res) => Some(res),
5858
_ => None,
@@ -65,7 +65,7 @@ impl<Fut: Future> MaybeDone<Fut> {
6565
#[inline]
6666
pub fn take_output(self: Pin<&mut Self>) -> Option<Fut::Output> {
6767
unsafe {
68-
let this = Pin::get_unchecked_mut(self);
68+
let this = self.get_unchecked_mut();
6969
match this {
7070
MaybeDone::Done(_) => {},
7171
MaybeDone::Future(_) | MaybeDone::Gone => return None,
@@ -93,7 +93,7 @@ impl<Fut: Future> Future for MaybeDone<Fut> {
9393

9494
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
9595
let res = unsafe {
96-
match Pin::get_unchecked_mut(self.as_mut()) {
96+
match self.as_mut().get_unchecked_mut() {
9797
MaybeDone::Future(a) => ready!(Pin::new_unchecked(a).poll(cx)),
9898
MaybeDone::Done(_) => return Poll::Ready(()),
9999
MaybeDone::Gone => panic!("MaybeDone polled after value taken"),

futures-util/src/io/buf_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<R: AsyncRead> AsyncBufRead for BufReader<R> {
176176
self: Pin<&'a mut Self>,
177177
cx: &mut Context<'_>,
178178
) -> Poll<io::Result<&'a [u8]>> {
179-
let Self { inner, buf, cap, pos } = unsafe { Pin::get_unchecked_mut(self) };
179+
let Self { inner, buf, cap, pos } = unsafe { self.get_unchecked_mut() };
180180
let mut inner = unsafe { Pin::new_unchecked(inner) };
181181

182182
// If we've reached the end of our internal buffer then we need to fetch

futures-util/src/io/buf_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<W: AsyncWrite> BufWriter<W> {
5353
}
5454

5555
fn flush_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
56-
let Self { inner, buf, written } = unsafe { Pin::get_unchecked_mut(self) };
56+
let Self { inner, buf, written } = unsafe { self.get_unchecked_mut() };
5757
let mut inner = unsafe { Pin::new_unchecked(inner) };
5858

5959
let len = buf.len();

futures-util/src/io/lines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<R: AsyncBufRead> Stream for Lines<R> {
3333
type Item = io::Result<String>;
3434

3535
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
36-
let Self { reader, buf, bytes, read } = unsafe { Pin::get_unchecked_mut(self) };
36+
let Self { reader, buf, bytes, read } = unsafe { self.get_unchecked_mut() };
3737
let reader = unsafe { Pin::new_unchecked(reader) };
3838
let n = ready!(read_line_internal(reader, buf, bytes, read, cx))?;
3939
if n == 0 && buf.is_empty() {

futures-util/src/sink/fanout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<Si1, Si2> Fanout<Si1, Si2> {
3636
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut Si1>, Pin<&'a mut Si2>)
3737
where Si1: Unpin, Si2: Unpin,
3838
{
39-
let Self { sink1, sink2 } = Pin::get_mut(self);
39+
let Self { sink1, sink2 } = self.get_mut();
4040
(Pin::new(sink1), Pin::new(sink2))
4141
}
4242

futures-util/src/sink/with.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<Fut, T> State<Fut, T> {
6363
self: Pin<&'a mut Self>,
6464
) -> State<Pin<&'a mut Fut>, Pin<&'a mut T>> {
6565
unsafe {
66-
match Pin::get_unchecked_mut(self) {
66+
match self.get_unchecked_mut() {
6767
State::Empty =>
6868
State::Empty,
6969
State::Process(fut) =>
@@ -132,7 +132,7 @@ impl<Si, Item, U, Fut, F, E> With<Si, Item, U, Fut, F>
132132
if let Some(buffered) = buffered {
133133
self.as_mut().state().set(State::Buffered(buffered));
134134
}
135-
if let State::Buffered(item) = unsafe { mem::replace(Pin::get_unchecked_mut(self.as_mut().state()), State::Empty) } {
135+
if let State::Buffered(item) = unsafe { mem::replace(self.as_mut().state().get_unchecked_mut(), State::Empty) } {
136136
Poll::Ready(self.as_mut().sink().start_send(item).map_err(Into::into))
137137
} else {
138138
unreachable!()

futures-util/src/sink/with_flat_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ where
7676
cx: &mut Context<'_>,
7777
) -> Poll<Result<(), Si::SinkError>> {
7878
let WithFlatMap { sink, stream, buffer, .. } =
79-
unsafe { Pin::get_unchecked_mut(self) };
79+
unsafe { self.get_unchecked_mut() };
8080
let mut sink = unsafe { Pin::new_unchecked(sink) };
8181
let mut stream = unsafe { Pin::new_unchecked(stream) };
8282

futures-util/src/stream/into_future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<St: Stream + Unpin> StreamFuture<St> {
5454
/// in order to return it to the caller of `Future::poll` if the stream yielded
5555
/// an element.
5656
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Option<Pin<&'a mut St>> {
57-
Pin::new(&mut Pin::get_mut(self).stream).as_pin_mut()
57+
Pin::new(&mut self.get_mut().stream).as_pin_mut()
5858
}
5959

6060
/// Consumes this combinator, returning the underlying stream.

futures-util/src/stream/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<St1, St2> Select<St1, St2> {
5959
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut St1>, Pin<&'a mut St2>)
6060
where St1: Unpin, St2: Unpin,
6161
{
62-
let Self { stream1, stream2, .. } = Pin::get_mut(self);
62+
let Self { stream1, stream2, .. } = self.get_mut();
6363
(Pin::new(stream1.get_mut()), Pin::new(stream2.get_mut()))
6464
}
6565

@@ -89,7 +89,7 @@ impl<St1, St2> Stream for Select<St1, St2>
8989
cx: &mut Context<'_>,
9090
) -> Poll<Option<St1::Item>> {
9191
let Select { flag, stream1, stream2 } =
92-
unsafe { Pin::get_unchecked_mut(self) };
92+
unsafe { self.get_unchecked_mut() };
9393
let stream1 = unsafe { Pin::new_unchecked(stream1) };
9494
let stream2 = unsafe { Pin::new_unchecked(stream2) };
9595

futures-util/src/stream/zip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl<St1: Stream, St2: Stream> Zip<St1, St2> {
6060
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> (Pin<&'a mut St1>, Pin<&'a mut St2>)
6161
where St1: Unpin, St2: Unpin,
6262
{
63-
let Self { stream1, stream2, .. } = Pin::get_mut(self);
63+
let Self { stream1, stream2, .. } = self.get_mut();
6464
(Pin::new(stream1.get_mut()), Pin::new(stream2.get_mut()))
6565
}
6666

futures-util/src/try_future/flatten_stream_sink.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ enum State<Fut, S> {
5959
impl<Fut, S> State<Fut, S> {
6060
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> State<Pin<&'a mut Fut>, Pin<&'a mut S>> {
6161
// safety: data is never moved via the resulting &mut reference
62-
match unsafe { Pin::get_unchecked_mut(self) } {
62+
match unsafe { self.get_unchecked_mut() } {
6363
// safety: the future we're re-pinning here will never be moved;
6464
// it will just be polled, then dropped in place
6565
State::Future(f) => State::Future(unsafe { Pin::new_unchecked(f) }),

futures-util/src/try_future/try_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<Fut1, Fut2, Data> TryChain<Fut1, Fut2, Data>
4242
let mut f = Some(f);
4343

4444
// Safe to call `get_unchecked_mut` because we won't move the futures.
45-
let this = unsafe { Pin::get_unchecked_mut(self) };
45+
let this = unsafe { self.get_unchecked_mut() };
4646

4747
loop {
4848
let (output, data) = match this {

0 commit comments

Comments
 (0)