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() {

0 commit comments

Comments
 (0)