Skip to content

Commit 572a3f6

Browse files
taiki-ecramertj
authored andcommitted
Reduce unsafe code
1 parent 0c68d49 commit 572a3f6

30 files changed

+30
-30
lines changed

futures-util/src/sink/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<Si: Sink<Item>, Item> Buffer<Si, Item> {
4343

4444
/// Get a pinned mutable reference to the inner sink.
4545
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
46-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
46+
self.sink()
4747
}
4848

4949
/// Consumes this combinator, returning the underlying sink.

futures-util/src/sink/err_into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<Si, E, Item> SinkErrInto<Si, Item, E>
3636

3737
/// Get a pinned mutable reference to the inner sink.
3838
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
39-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
39+
self.sink().get_pin_mut()
4040
}
4141

4242
/// Consumes this combinator, returning the underlying sink.

futures-util/src/sink/map_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<Si, F> SinkMapErr<Si, F> {
3434

3535
/// Get a pinned mutable reference to the inner sink.
3636
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
37-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
37+
self.sink()
3838
}
3939

4040
/// Consumes this combinator, returning the underlying sink.

futures-util/src/sink/with.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<Si, Item, U, Fut, F, E> With<Si, Item, U, Fut, F>
109109

110110
/// Get a pinned mutable reference to the inner sink.
111111
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
112-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
112+
self.sink()
113113
}
114114

115115
/// Consumes this combinator, returning the underlying sink.

futures-util/src/sink/with_flat_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ where
6060

6161
/// Get a pinned mutable reference to the inner sink.
6262
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut Si> {
63-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
63+
self.sink()
6464
}
6565

6666
/// Consumes this combinator, returning the underlying sink.

futures-util/src/stream/buffer_unordered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ where
8181
/// Note that care must be taken to avoid tampering with the state of the
8282
/// stream which may otherwise confuse this combinator.
8383
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
84-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
84+
self.stream().get_pin_mut()
8585
}
8686

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

futures-util/src/stream/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ where
7676
/// Note that care must be taken to avoid tampering with the state of the
7777
/// stream which may otherwise confuse this combinator.
7878
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
79-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
79+
self.stream().get_pin_mut()
8080
}
8181

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

futures-util/src/stream/chunks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<St: Stream> Chunks<St> where St: Stream {
5858
/// Note that care must be taken to avoid tampering with the state of the
5959
/// stream which may otherwise confuse this combinator.
6060
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
61-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
61+
self.stream().get_pin_mut()
6262
}
6363

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

futures-util/src/stream/enumerate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<St: Stream> Enumerate<St> {
4646
/// Note that care must be taken to avoid tampering with the state of the
4747
/// stream which may otherwise confuse this combinator.
4848
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
49-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
49+
self.stream()
5050
}
5151

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

futures-util/src/stream/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ where St: Stream,
5959
/// Note that care must be taken to avoid tampering with the state of the
6060
/// stream which may otherwise confuse this combinator.
6161
pub fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut St> {
62-
unsafe { Pin::map_unchecked_mut(self, Self::get_mut) }
62+
self.stream()
6363
}
6464

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

0 commit comments

Comments
 (0)