-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
async_write.expanded.rs
120 lines (120 loc) · 3.73 KB
/
async_write.expanded.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
extern crate tokio1_crate as tokio;
use auto_enums::enum_derive;
enum Enum<A, B> {
A(A),
B(B),
}
impl<A, B> ::tokio::io::AsyncWrite for Enum<A, B>
where
A: ::tokio::io::AsyncWrite,
B: ::tokio::io::AsyncWrite,
{
fn is_write_vectored(&self) -> bool {
match self {
Enum::A(x) => <A as ::tokio::io::AsyncWrite>::is_write_vectored(x),
Enum::B(x) => <B as ::tokio::io::AsyncWrite>::is_write_vectored(x),
}
}
fn poll_write(
self: ::core::pin::Pin<&mut Self>,
cx: &mut ::core::task::Context<'_>,
buf: &[u8],
) -> ::core::task::Poll<::std::io::Result<usize>> {
unsafe {
match self.get_unchecked_mut() {
Enum::A(x) => {
<A as ::tokio::io::AsyncWrite>::poll_write(
::core::pin::Pin::new_unchecked(x),
cx,
buf,
)
}
Enum::B(x) => {
<B as ::tokio::io::AsyncWrite>::poll_write(
::core::pin::Pin::new_unchecked(x),
cx,
buf,
)
}
}
}
}
fn poll_flush(
self: ::core::pin::Pin<&mut Self>,
cx: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<::std::io::Result<()>> {
unsafe {
match self.get_unchecked_mut() {
Enum::A(x) => {
<A as ::tokio::io::AsyncWrite>::poll_flush(
::core::pin::Pin::new_unchecked(x),
cx,
)
}
Enum::B(x) => {
<B as ::tokio::io::AsyncWrite>::poll_flush(
::core::pin::Pin::new_unchecked(x),
cx,
)
}
}
}
}
fn poll_shutdown(
self: ::core::pin::Pin<&mut Self>,
cx: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<::std::io::Result<()>> {
unsafe {
match self.get_unchecked_mut() {
Enum::A(x) => {
<A as ::tokio::io::AsyncWrite>::poll_shutdown(
::core::pin::Pin::new_unchecked(x),
cx,
)
}
Enum::B(x) => {
<B as ::tokio::io::AsyncWrite>::poll_shutdown(
::core::pin::Pin::new_unchecked(x),
cx,
)
}
}
}
}
fn poll_write_vectored(
self: ::core::pin::Pin<&mut Self>,
cx: &mut ::core::task::Context<'_>,
bufs: &[::std::io::IoSlice<'_>],
) -> ::core::task::Poll<::std::io::Result<usize>> {
unsafe {
match self.get_unchecked_mut() {
Enum::A(x) => {
<A as ::tokio::io::AsyncWrite>::poll_write_vectored(
::core::pin::Pin::new_unchecked(x),
cx,
bufs,
)
}
Enum::B(x) => {
<B as ::tokio::io::AsyncWrite>::poll_write_vectored(
::core::pin::Pin::new_unchecked(x),
cx,
bufs,
)
}
}
}
}
}
impl<A, B> ::core::marker::Unpin for Enum<A, B>
where
A: ::core::marker::Unpin,
B: ::core::marker::Unpin,
{}
const _: () = {
trait MustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: ::core::ops::Drop> MustNotImplDrop for T {}
impl<A, B> MustNotImplDrop for Enum<A, B> {}
};
fn main() {}