• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vigna / epserde-rs / 28520964893

01 Jul 2026 01:25PM UTC coverage: 43.952% (+0.07%) from 43.882%
28520964893

push

github

vigna
Better naming for methods and errors

8 of 13 new or added lines in 4 files covered. (61.54%)

333 existing lines in 7 files now uncovered.

883 of 2009 relevant lines covered (43.95%)

447.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.56
/epserde/src/impls/stdlib.rs
1
/*
2
 * SPDX-FileCopyrightText: 2023 Tommaso Fontana
3
 * SPDX-FileCopyrightText: 2025 Sebastiano Vigna
4
 *
5
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
6
 */
7

8
//! Implementation for structures from the standard library.
9
//!
10
//! Note that none of these types can be zero-copy (unless they are empty, as in
11
//! the case of [`RangeFull`]), because they are not `repr(C)`.
12

13
use ser::WriteWithNames;
14

15
use crate::{check_covariance, prelude::*};
16
use core::hash::{BuildHasherDefault, Hash};
17
use core::ops::{
18
    Bound, ControlFlow, Range, RangeBounds, RangeFrom, RangeFull, RangeInclusive, RangeTo,
19
    RangeToInclusive,
20
};
21

22
#[cfg(feature = "std")]
23
use std::hash::DefaultHasher;
24

25
// This implementation makes it possible to serialize
26
// PhantomData<DefaultHasher>.
27
#[cfg(feature = "std")]
28
impl TypeHash for DefaultHasher {
29
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
4✔
30
        "std::hash::DefaultHasher".hash(hasher);
12✔
31
    }
32
}
33

34
unsafe impl<H> CopyType for BuildHasherDefault<H> {
35
    type Copy = Zero;
36
}
37

38
impl<H> AlignTo for BuildHasherDefault<H> {
39
    fn align_to() -> usize {
×
UNCOV
40
        0
×
41
    }
42
}
43

44
impl<H: TypeHash> TypeHash for BuildHasherDefault<H> {
45
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
3✔
46
        "core::hash::BuildHasherDefault".hash(hasher);
9✔
47
        H::type_hash(hasher);
6✔
48
    }
49
}
50

51
impl<H> AlignHash for BuildHasherDefault<H> {
52
    fn align_hash(_hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {}
6✔
53
}
54

55
impl<H> SerInner for BuildHasherDefault<H> {
56
    type SerType = BuildHasherDefault<H>;
57
    const IS_ZERO_COPY: bool = true;
58
    const MIGHT_BE_ZERO_COPY: bool = true;
59

60
    unsafe fn _ser_inner(&self, _backend: &mut impl WriteWithNames) -> ser::Result<()> {
1✔
61
        Ok(())
1✔
62
    }
63
}
64

65
impl<H> DeserInner for BuildHasherDefault<H> {
66
    check_covariance!();
67
    unsafe fn _deser_full_inner(_backend: &mut impl ReadWithPos) -> deser::Result<Self> {
1✔
68
        Ok(BuildHasherDefault::default())
1✔
69
    }
70

71
    // Zero-copy zero-sized types from the standard library are ε-copy deserialized by value
72
    type DeserType<'a> = BuildHasherDefault<H>;
73

74
    unsafe fn _deser_eps_inner<'a>(
1✔
75
        _backend: &mut SliceWithPos<'a>,
76
    ) -> deser::Result<Self::DeserType<'a>> {
77
        Ok(BuildHasherDefault::default())
1✔
78
    }
79
}
80

81
macro_rules! impl_ranges {
82
    ($ty:ident) => {
83
        unsafe impl<Idx> CopyType for $ty<Idx> {
84
            type Copy = Deep;
85
        }
86

87
        impl<Idx: TypeHash> TypeHash for $ty<Idx> {
88
            fn type_hash(hasher: &mut impl core::hash::Hasher) {
21✔
89
                stringify!(core::ops::$ty).hash(hasher);
63✔
90
                Idx::type_hash(hasher);
42✔
91
            }
92
        }
93
    };
94
}
95

96
impl_ranges!(Range);
97
impl_ranges!(RangeFrom);
98
impl_ranges!(RangeInclusive);
99
impl_ranges!(RangeTo);
100
impl_ranges!(RangeToInclusive);
101

102
impl<Idx: AlignHash> AlignHash for Range<Idx> {
103
    fn align_hash(hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {
13✔
104
        Idx::align_hash(hasher, &mut 0);
39✔
105
        Idx::align_hash(hasher, &mut 0);
39✔
106
    }
107
}
108

109
impl<Idx: AlignHash> AlignHash for RangeFrom<Idx> {
110
    fn align_hash(hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {
1✔
111
        Idx::align_hash(hasher, &mut 0);
3✔
112
    }
113
}
114

115
impl<Idx: AlignHash> AlignHash for RangeInclusive<Idx> {
116
    fn align_hash(hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {
5✔
117
        Idx::align_hash(hasher, &mut 0);
15✔
118
        Idx::align_hash(hasher, &mut 0);
15✔
119
        bool::align_hash(hasher, &mut 0);
15✔
120
    }
121
}
122

123
impl<Idx: AlignHash> AlignHash for RangeTo<Idx> {
124
    fn align_hash(hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {
1✔
125
        Idx::align_hash(hasher, &mut 0);
3✔
126
    }
127
}
128

129
impl<Idx: AlignHash> AlignHash for RangeToInclusive<Idx> {
130
    fn align_hash(hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {
1✔
131
        Idx::align_hash(hasher, &mut 0);
3✔
132
    }
133
}
134

135
// RangeFull is a zero-sized type, so it is always zero-copy.
136

137
unsafe impl CopyType for RangeFull {
138
    type Copy = Zero;
139
}
140

141
impl TypeHash for RangeFull {
142
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
1✔
143
        stringify!(core::ops::RangeFull).hash(hasher);
3✔
144
    }
145
}
146

147
impl AlignHash for RangeFull {
148
    fn align_hash(_hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {}
2✔
149
}
150

151
impl AlignTo for RangeFull {
152
    fn align_to() -> usize {
×
UNCOV
153
        0
×
154
    }
155
}
156

157
impl<Idx: SerInner> SerInner for Range<Idx> {
158
    type SerType = Range<Idx::SerType>;
159
    const IS_ZERO_COPY: bool = false;
160
    const MIGHT_BE_ZERO_COPY: bool = false;
161

162
    #[inline(always)]
163
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
4✔
164
        backend.write("start", &self.start)?;
16✔
165
        backend.write("end", &self.end)?;
16✔
166
        Ok(())
4✔
167
    }
168
}
169

170
impl<Idx: DeserInner> DeserInner for Range<Idx> {
171
    // SAFETY: Range is covariant in Idx, and Idx::DeserType is covariant
172
    // (enforced by Idx's own __check_covariance).
173
    crate::unsafe_assume_covariance!(Idx);
174
    #[inline(always)]
175
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
4✔
176
        let start = unsafe { Idx::_deser_full_inner(backend) }?;
12✔
177
        let end = unsafe { Idx::_deser_full_inner(backend) }?;
12✔
178
        Ok(Range { start, end })
4✔
179
    }
180
    type DeserType<'a> = Range<DeserType<'a, Idx>>;
181
    #[inline(always)]
182
    unsafe fn _deser_eps_inner<'a>(
2✔
183
        backend: &mut SliceWithPos<'a>,
184
    ) -> deser::Result<Self::DeserType<'a>> {
185
        let start = unsafe { Idx::_deser_eps_inner(backend) }?;
6✔
186
        let end = unsafe { Idx::_deser_eps_inner(backend) }?;
6✔
187
        Ok(Range { start, end })
2✔
188
    }
189
}
190

191
impl<Idx: SerInner> SerInner for RangeFrom<Idx> {
192
    type SerType = RangeFrom<Idx::SerType>;
193
    const IS_ZERO_COPY: bool = false;
194
    const MIGHT_BE_ZERO_COPY: bool = false;
195

196
    #[inline(always)]
197
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
×
198
        backend.write("start", &self.start)?;
×
UNCOV
199
        Ok(())
×
200
    }
201
}
202

203
impl<Idx: DeserInner> DeserInner for RangeFrom<Idx> {
204
    // SAFETY: RangeFrom is covariant in Idx, and Idx::DeserType is covariant
205
    // (enforced by Idx's own __check_covariance).
206
    crate::unsafe_assume_covariance!(Idx);
207
    #[inline(always)]
208
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
×
209
        let start = unsafe { Idx::_deser_full_inner(backend) }?;
×
UNCOV
210
        Ok(RangeFrom { start })
×
211
    }
212
    type DeserType<'a> = RangeFrom<DeserType<'a, Idx>>;
213
    #[inline(always)]
UNCOV
214
    unsafe fn _deser_eps_inner<'a>(
×
215
        backend: &mut SliceWithPos<'a>,
216
    ) -> deser::Result<Self::DeserType<'a>> {
217
        let start = unsafe { Idx::_deser_eps_inner(backend) }?;
×
UNCOV
218
        Ok(RangeFrom { start })
×
219
    }
220
}
221

222
impl<Idx: SerInner> SerInner for RangeInclusive<Idx> {
223
    type SerType = RangeInclusive<Idx::SerType>;
224
    const IS_ZERO_COPY: bool = false;
225
    const MIGHT_BE_ZERO_COPY: bool = false;
226

227
    #[inline(always)]
228
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
2✔
229
        // An exhausted range reports its end bound as excluded, but
230
        // deserialization can only reconstruct non-exhausted ranges
231
        if matches!(self.end_bound(), Bound::Excluded(_)) {
3✔
232
            return Err(ser::Error::ExhaustedRange);
1✔
233
        }
234
        backend.write("start", self.start())?;
4✔
235
        backend.write("end", self.end())?;
4✔
236
        Ok(())
1✔
237
    }
238
}
239

240
impl<Idx: DeserInner> DeserInner for RangeInclusive<Idx> {
241
    // SAFETY: RangeInclusive is covariant in Idx, and Idx::DeserType is
242
    // covariant (enforced by Idx's own __check_covariance).
243
    crate::unsafe_assume_covariance!(Idx);
244
    #[inline(always)]
245
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
1✔
246
        let start = unsafe { Idx::_deser_full_inner(backend) }?;
3✔
247
        let end = unsafe { Idx::_deser_full_inner(backend) }?;
3✔
248
        Ok(start..=end)
1✔
249
    }
250
    type DeserType<'a> = RangeInclusive<DeserType<'a, Idx>>;
251
    #[inline(always)]
252
    unsafe fn _deser_eps_inner<'a>(
1✔
253
        backend: &mut SliceWithPos<'a>,
254
    ) -> deser::Result<Self::DeserType<'a>> {
255
        let start = unsafe { Idx::_deser_eps_inner(backend) }?;
3✔
256
        let end = unsafe { Idx::_deser_eps_inner(backend) }?;
3✔
257
        Ok(start..=end)
1✔
258
    }
259
}
260

261
impl<Idx: SerInner> SerInner for RangeTo<Idx> {
262
    type SerType = RangeTo<Idx::SerType>;
263
    const IS_ZERO_COPY: bool = false;
264
    const MIGHT_BE_ZERO_COPY: bool = false;
265

266
    #[inline(always)]
267
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
×
268
        backend.write("end", &self.end)?;
×
UNCOV
269
        Ok(())
×
270
    }
271
}
272

273
impl<Idx: DeserInner> DeserInner for RangeTo<Idx> {
274
    // SAFETY: RangeTo is covariant in Idx, and Idx::DeserType is covariant
275
    // (enforced by Idx's own __check_covariance).
276
    crate::unsafe_assume_covariance!(Idx);
277
    #[inline(always)]
278
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
×
279
        let end = unsafe { Idx::_deser_full_inner(backend) }?;
×
UNCOV
280
        Ok(..end)
×
281
    }
282
    type DeserType<'a> = RangeTo<DeserType<'a, Idx>>;
283
    #[inline(always)]
UNCOV
284
    unsafe fn _deser_eps_inner<'a>(
×
285
        backend: &mut SliceWithPos<'a>,
286
    ) -> deser::Result<Self::DeserType<'a>> {
287
        let end = unsafe { Idx::_deser_eps_inner(backend) }?;
×
UNCOV
288
        Ok(..end)
×
289
    }
290
}
291

292
impl<Idx: SerInner> SerInner for RangeToInclusive<Idx> {
293
    type SerType = RangeToInclusive<Idx::SerType>;
294
    const IS_ZERO_COPY: bool = false;
295
    const MIGHT_BE_ZERO_COPY: bool = false;
296

297
    #[inline(always)]
298
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
×
299
        backend.write("end", &self.end)?;
×
UNCOV
300
        Ok(())
×
301
    }
302
}
303

304
impl<Idx: DeserInner> DeserInner for RangeToInclusive<Idx> {
305
    // SAFETY: RangeToInclusive is covariant in Idx, and Idx::DeserType is
306
    // covariant (enforced by Idx's own __check_covariance).
307
    crate::unsafe_assume_covariance!(Idx);
308
    #[inline(always)]
309
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
×
310
        let end = unsafe { Idx::_deser_full_inner(backend) }?;
×
UNCOV
311
        Ok(..=end)
×
312
    }
313
    type DeserType<'a> = RangeToInclusive<DeserType<'a, Idx>>;
314
    #[inline(always)]
UNCOV
315
    unsafe fn _deser_eps_inner<'a>(
×
316
        backend: &mut SliceWithPos<'a>,
317
    ) -> deser::Result<Self::DeserType<'a>> {
318
        let end = unsafe { Idx::_deser_eps_inner(backend) }?;
×
UNCOV
319
        Ok(..=end)
×
320
    }
321
}
322

323
impl SerInner for RangeFull {
324
    type SerType = RangeFull;
325
    const IS_ZERO_COPY: bool = true;
326
    const MIGHT_BE_ZERO_COPY: bool = true;
327

328
    #[inline(always)]
329
    unsafe fn _ser_inner(&self, _backend: &mut impl WriteWithNames) -> ser::Result<()> {
×
UNCOV
330
        Ok(())
×
331
    }
332
}
333

334
impl DeserInner for RangeFull {
335
    check_covariance!();
336
    #[inline(always)]
337
    unsafe fn _deser_full_inner(_backend: &mut impl ReadWithPos) -> deser::Result<Self> {
×
UNCOV
338
        Ok(RangeFull)
×
339
    }
340
    // Zero-copy zero-sized types from the standard library are ε-copy deserialized by value
341
    type DeserType<'a> = RangeFull;
342
    #[inline(always)]
UNCOV
343
    unsafe fn _deser_eps_inner<'a>(
×
344
        _backend: &mut SliceWithPos<'a>,
345
    ) -> deser::Result<Self::DeserType<'a>> {
UNCOV
346
        Ok(RangeFull)
×
347
    }
348
}
349

350
unsafe impl<T> CopyType for Bound<T> {
351
    type Copy = Deep;
352
}
353

354
impl<T: TypeHash> TypeHash for Bound<T> {
355
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
19✔
356
        stringify!(core::ops::Bound).hash(hasher);
57✔
357
        T::type_hash(hasher);
38✔
358
    }
359
}
360

361
impl<T> AlignHash for Bound<T> {
362
    fn align_hash(_hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {}
38✔
363
}
364

365
impl<T: SerInner> SerInner for Bound<T> {
366
    type SerType = Bound<T::SerType>;
367
    const IS_ZERO_COPY: bool = false;
368
    const MIGHT_BE_ZERO_COPY: bool = false;
369

370
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
6✔
371
        match self {
6✔
372
            Bound::Unbounded => backend.write("Tag", &0_u8),
8✔
373
            Bound::Included(val) => {
2✔
374
                backend.write("Tag", &1_u8)?;
8✔
375
                backend.write("Included", val)
8✔
376
            }
377
            Bound::Excluded(val) => {
2✔
378
                backend.write("Tag", &2_u8)?;
8✔
379
                backend.write("Excluded", val)
8✔
380
            }
381
        }
382
    }
383
}
384

385
impl<T: DeserInner> DeserInner for Bound<T> {
386
    // SAFETY: Bound is covariant in T, and T::DeserType is covariant
387
    // (enforced by T's own __check_covariance).
388
    crate::unsafe_assume_covariance!(T);
389
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
6✔
390
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
18✔
391
        match tag {
6✔
392
            0 => Ok(Bound::Unbounded),
2✔
393
            1 => Ok(Bound::Included(unsafe { T::_deser_full_inner(backend) }?)),
4✔
394
            2 => Ok(Bound::Excluded(unsafe { T::_deser_full_inner(backend) }?)),
4✔
UNCOV
395
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
396
        }
397
    }
398

399
    type DeserType<'a> = Bound<DeserType<'a, T>>;
400

401
    unsafe fn _deser_eps_inner<'a>(
6✔
402
        backend: &mut SliceWithPos<'a>,
403
    ) -> deser::Result<Self::DeserType<'a>> {
404
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
18✔
405
        match tag {
6✔
406
            0 => Ok(Bound::Unbounded),
2✔
407
            1 => Ok(Bound::Included(unsafe { T::_deser_eps_inner(backend) }?)),
4✔
408
            2 => Ok(Bound::Excluded(unsafe { T::_deser_eps_inner(backend) }?)),
4✔
UNCOV
409
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
410
        }
411
    }
412
}
413

414
unsafe impl<B, C> CopyType for ControlFlow<B, C> {
415
    type Copy = Deep;
416
}
417

418
impl<B: TypeHash, C: TypeHash> TypeHash for ControlFlow<B, C> {
419
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
13✔
420
        stringify!(core::ops::ControlFlow).hash(hasher);
39✔
421
        B::type_hash(hasher);
26✔
422
        C::type_hash(hasher);
26✔
423
    }
424
}
425

426
impl<B, C> AlignHash for ControlFlow<B, C> {
427
    fn align_hash(_hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {}
26✔
428
}
429

430
impl<B: SerInner, C: SerInner> SerInner for ControlFlow<B, C> {
431
    type SerType = ControlFlow<B::SerType, C::SerType>;
432
    const IS_ZERO_COPY: bool = false;
433
    const MIGHT_BE_ZERO_COPY: bool = false;
434

435
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
4✔
436
        match self {
4✔
437
            ControlFlow::Break(br) => {
2✔
438
                backend.write("Tag", &0_u8)?;
8✔
439
                backend.write("Break", br)
8✔
440
            }
441
            ControlFlow::Continue(val) => {
2✔
442
                backend.write("Tag", &1_u8)?;
8✔
443
                backend.write("Continue", val)
8✔
444
            }
445
        }
446
    }
447
}
448

449
impl<B: DeserInner, C: DeserInner> DeserInner for ControlFlow<B, C> {
450
    // SAFETY: ControlFlow is covariant in B and C, and both B::DeserType
451
    // and C::DeserType are covariant (enforced by their own __check_covariance).
452
    crate::unsafe_assume_covariance!(B, C);
453
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
4✔
454
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
12✔
455
        match tag {
4✔
UNCOV
456
            0 => Ok(ControlFlow::Break(unsafe {
×
457
                B::_deser_full_inner(backend)
4✔
458
            }?)),
UNCOV
459
            1 => Ok(ControlFlow::Continue(unsafe {
×
460
                C::_deser_full_inner(backend)
4✔
461
            }?)),
UNCOV
462
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
463
        }
464
    }
465

466
    type DeserType<'a> = ControlFlow<DeserType<'a, B>, DeserType<'a, C>>;
467

468
    unsafe fn _deser_eps_inner<'a>(
4✔
469
        backend: &mut SliceWithPos<'a>,
470
    ) -> deser::Result<Self::DeserType<'a>> {
471
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
12✔
472
        match tag {
4✔
473
            0 => Ok(ControlFlow::Break(unsafe { B::_deser_eps_inner(backend) }?)),
4✔
UNCOV
474
            1 => Ok(ControlFlow::Continue(unsafe {
×
475
                C::_deser_eps_inner(backend)
4✔
476
            }?)),
UNCOV
477
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
478
        }
479
    }
480
}
481

482
unsafe impl<T, E> CopyType for Result<T, E> {
483
    type Copy = Deep;
484
}
485

486
impl<T: TypeHash, E: TypeHash> TypeHash for Result<T, E> {
487
    fn type_hash(hasher: &mut impl core::hash::Hasher) {
12✔
488
        "core::result::Result".hash(hasher);
36✔
489
        T::type_hash(hasher);
24✔
490
        E::type_hash(hasher);
24✔
491
    }
492
}
493

494
impl<T, E> AlignHash for Result<T, E> {
495
    fn align_hash(_hasher: &mut impl core::hash::Hasher, _offset_of: &mut usize) {}
24✔
496
}
497

498
impl<T: SerInner, E: SerInner> SerInner for Result<T, E> {
499
    type SerType = Result<T::SerType, E::SerType>;
500
    const IS_ZERO_COPY: bool = false;
501
    const MIGHT_BE_ZERO_COPY: bool = false;
502

503
    unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> ser::Result<()> {
4✔
504
        match self {
4✔
505
            Ok(val) => {
2✔
506
                backend.write("Tag", &0_u8)?;
8✔
507
                backend.write("Ok", val)
8✔
508
            }
509
            Err(err) => {
2✔
510
                backend.write("Tag", &1_u8)?;
8✔
511
                backend.write("Err", err)
8✔
512
            }
513
        }
514
    }
515
}
516

517
impl<T: DeserInner, E: DeserInner> DeserInner for Result<T, E> {
518
    // SAFETY: Result is covariant in T and E, and both T::DeserType and
519
    // E::DeserType are covariant (enforced by their own __check_covariance).
520
    crate::unsafe_assume_covariance!(T, E);
521
    unsafe fn _deser_full_inner(backend: &mut impl ReadWithPos) -> deser::Result<Self> {
4✔
522
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
12✔
523
        match tag {
4✔
524
            0 => Ok(Ok(unsafe { T::_deser_full_inner(backend) }?)),
4✔
525
            1 => Ok(Err(unsafe { E::_deser_full_inner(backend) }?)),
4✔
UNCOV
526
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
527
        }
528
    }
529

530
    type DeserType<'a> = Result<DeserType<'a, T>, DeserType<'a, E>>;
531

532
    unsafe fn _deser_eps_inner<'a>(
4✔
533
        backend: &mut SliceWithPos<'a>,
534
    ) -> deser::Result<Self::DeserType<'a>> {
535
        let tag = unsafe { u8::_deser_full_inner(backend) }?;
12✔
536
        match tag {
4✔
537
            0 => Ok(Ok(unsafe { T::_deser_eps_inner(backend) }?)),
4✔
538
            1 => Ok(Err(unsafe { E::_deser_eps_inner(backend) }?)),
4✔
UNCOV
539
            _ => Err(deser::Error::InvalidTag(tag as usize)),
×
540
        }
541
    }
542
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc