Skip to content

Commit 2889cbe

Browse files
committed
Make Ivar forwarding impls generic over Deref::Target
1 parent d55581c commit 2889cbe

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

objc2/src/declare/ivar_forwarding_impls.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use super::{Ivar, IvarType};
2424

2525
impl<T: IvarType> PartialEq for Ivar<T>
2626
where
27-
T::Type: PartialEq,
27+
<Self as Deref>::Target: PartialEq,
2828
{
2929
#[inline]
3030
fn eq(&self, other: &Self) -> bool {
@@ -38,11 +38,11 @@ where
3838
}
3939
}
4040

41-
impl<T: IvarType> Eq for Ivar<T> where T::Type: Eq {}
41+
impl<T: IvarType> Eq for Ivar<T> where <Self as Deref>::Target: Eq {}
4242

4343
impl<T: IvarType> PartialOrd for Ivar<T>
4444
where
45-
T::Type: PartialOrd,
45+
<Self as Deref>::Target: PartialOrd,
4646
{
4747
#[inline]
4848
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
@@ -68,7 +68,7 @@ where
6868

6969
impl<T: IvarType> Ord for Ivar<T>
7070
where
71-
T::Type: Ord,
71+
<Self as Deref>::Target: Ord,
7272
{
7373
#[inline]
7474
fn cmp(&self, other: &Self) -> Ordering {
@@ -78,7 +78,7 @@ where
7878

7979
impl<T: IvarType> hash::Hash for Ivar<T>
8080
where
81-
T::Type: hash::Hash,
81+
<Self as Deref>::Target: hash::Hash,
8282
{
8383
fn hash<H: hash::Hasher>(&self, state: &mut H) {
8484
(**self).hash(state)
@@ -87,7 +87,7 @@ where
8787

8888
impl<T: IvarType> hash::Hasher for Ivar<T>
8989
where
90-
T::Type: hash::Hasher,
90+
<Self as Deref>::Target: hash::Hasher,
9191
{
9292
fn finish(&self) -> u64 {
9393
(**self).finish()
@@ -135,7 +135,7 @@ where
135135

136136
impl<T: IvarType> fmt::Display for Ivar<T>
137137
where
138-
T::Type: fmt::Display,
138+
<Self as Deref>::Target: fmt::Display,
139139
{
140140
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
141141
(**self).fmt(f)
@@ -144,7 +144,7 @@ where
144144

145145
impl<T: IvarType> fmt::Debug for Ivar<T>
146146
where
147-
T::Type: fmt::Debug,
147+
<Self as Deref>::Target: fmt::Debug,
148148
{
149149
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
150150
(**self).fmt(f)
@@ -153,70 +153,70 @@ where
153153

154154
impl<I: IvarType> Iterator for Ivar<I>
155155
where
156-
I::Type: Iterator,
156+
<Self as Deref>::Target: Iterator,
157157
{
158-
type Item = <I::Type as Iterator>::Item;
159-
fn next(&mut self) -> Option<<I::Type as Iterator>::Item> {
158+
type Item = <<Self as Deref>::Target as Iterator>::Item;
159+
fn next(&mut self) -> Option<<<Self as Deref>::Target as Iterator>::Item> {
160160
(**self).next()
161161
}
162162
fn size_hint(&self) -> (usize, Option<usize>) {
163163
(**self).size_hint()
164164
}
165-
fn nth(&mut self, n: usize) -> Option<<I::Type as Iterator>::Item> {
165+
fn nth(&mut self, n: usize) -> Option<<<Self as Deref>::Target as Iterator>::Item> {
166166
(**self).nth(n)
167167
}
168168
}
169169

170170
impl<I: IvarType> DoubleEndedIterator for Ivar<I>
171171
where
172-
I::Type: DoubleEndedIterator,
172+
<Self as Deref>::Target: DoubleEndedIterator,
173173
{
174-
fn next_back(&mut self) -> Option<<I::Type as Iterator>::Item> {
174+
fn next_back(&mut self) -> Option<<<Self as Deref>::Target as Iterator>::Item> {
175175
(**self).next_back()
176176
}
177-
fn nth_back(&mut self, n: usize) -> Option<<I::Type as Iterator>::Item> {
177+
fn nth_back(&mut self, n: usize) -> Option<<<Self as Deref>::Target as Iterator>::Item> {
178178
(**self).nth_back(n)
179179
}
180180
}
181181

182182
impl<I: IvarType> ExactSizeIterator for Ivar<I>
183183
where
184-
I::Type: ExactSizeIterator,
184+
<Self as Deref>::Target: ExactSizeIterator,
185185
{
186186
fn len(&self) -> usize {
187187
(**self).len()
188188
}
189189
}
190190

191-
impl<I: IvarType> FusedIterator for Ivar<I> where I::Type: FusedIterator {}
191+
impl<I: IvarType> FusedIterator for Ivar<I> where <Self as Deref>::Target: FusedIterator {}
192192

193-
// impl<T: IvarType> borrow::Borrow<T::Type> for Ivar<T> {
194-
// fn borrow(&self) -> &T::Type {
193+
// impl<T: IvarType> borrow::Borrow<<Self as Deref>::Target> for Ivar<T> {
194+
// fn borrow(&self) -> &<Self as Deref>::Target {
195195
// Deref::deref(self)
196196
// }
197197
// }
198198
//
199-
// impl<T: IvarType> borrow::BorrowMut<T::Type> for Ivar<T> {
200-
// fn borrow_mut(&mut self) -> &mut T::Type {
199+
// impl<T: IvarType> borrow::BorrowMut<<Self as Deref>::Target> for Ivar<T> {
200+
// fn borrow_mut(&mut self) -> &mut <Self as Deref>::Target {
201201
// DerefMut::deref_mut(self)
202202
// }
203203
// }
204204

205-
impl<T: IvarType> AsRef<T::Type> for Ivar<T> {
206-
fn as_ref(&self) -> &T::Type {
205+
impl<T: IvarType> AsRef<<Self as Deref>::Target> for Ivar<T> {
206+
fn as_ref(&self) -> &<Self as Deref>::Target {
207207
Deref::deref(self)
208208
}
209209
}
210210

211-
impl<T: IvarType> AsMut<T::Type> for Ivar<T> {
212-
fn as_mut(&mut self) -> &mut T::Type {
211+
impl<T: IvarType> AsMut<<Self as Deref>::Target> for Ivar<T> {
212+
fn as_mut(&mut self) -> &mut <Self as Deref>::Target {
213213
DerefMut::deref_mut(self)
214214
}
215215
}
216216

217217
impl<T: IvarType> Error for Ivar<T>
218218
where
219-
T::Type: Error,
219+
<Self as Deref>::Target: Error,
220220
{
221221
fn source(&self) -> Option<&(dyn Error + 'static)> {
222222
(**self).source()
@@ -225,7 +225,7 @@ where
225225

226226
impl<T: IvarType> io::Read for Ivar<T>
227227
where
228-
T::Type: io::Read,
228+
<Self as Deref>::Target: io::Read,
229229
{
230230
#[inline]
231231
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
@@ -255,7 +255,7 @@ where
255255

256256
impl<T: IvarType> io::Write for Ivar<T>
257257
where
258-
T::Type: io::Write,
258+
<Self as Deref>::Target: io::Write,
259259
{
260260
#[inline]
261261
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
@@ -285,7 +285,7 @@ where
285285

286286
impl<T: IvarType> io::Seek for Ivar<T>
287287
where
288-
T::Type: io::Seek,
288+
<Self as Deref>::Target: io::Seek,
289289
{
290290
#[inline]
291291
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
@@ -300,7 +300,7 @@ where
300300

301301
impl<T: IvarType> io::BufRead for Ivar<T>
302302
where
303-
T::Type: io::BufRead,
303+
<Self as Deref>::Target: io::BufRead,
304304
{
305305
#[inline]
306306
fn fill_buf(&mut self) -> io::Result<&[u8]> {
@@ -325,12 +325,12 @@ where
325325

326326
impl<T: IvarType> Future for Ivar<T>
327327
where
328-
T::Type: Future + Unpin,
328+
<Self as Deref>::Target: Future + Unpin,
329329
{
330-
type Output = <T::Type as Future>::Output;
330+
type Output = <<Self as Deref>::Target as Future>::Output;
331331

332332
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
333-
<T::Type as Future>::poll(Pin::new(&mut *self), cx)
333+
<<Self as Deref>::Target as Future>::poll(Pin::new(&mut *self), cx)
334334
}
335335
}
336336

0 commit comments

Comments
 (0)