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

Alorel / impl_index-rs / 14553724254

19 Apr 2025 11:13PM UTC coverage: 96.479% (-1.0%) from 97.512%
14553724254

push

github

Alorel
ci: Add `unexpected_cfgs` lint config

137 of 142 relevant lines covered (96.48%)

5.0 hits per line

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

93.18
/src/parse.rs
1
use syn::parse::{Parse, ParseStream};
2
use syn::{custom_keyword, Generics, Pat, Token};
3

4
use crate::{IndexMacro, MaybeIdent, Pairing, Pattern};
5

6
impl Parse for IndexMacro {
7
    fn parse(input: ParseStream) -> syn::Result<Self> {
2✔
8
        let (generics, impl_for) = {
2✔
9
            if input.peek(Token![<]) {
2✔
10
                if input.fork().parse::<Generics>().is_ok() {
×
11
                    (Some(input.parse()?), input.parse()?)
×
12
                } else {
13
                    (None, input.parse()?)
×
14
                }
15
            } else {
16
                (None, input.parse()?)
2✔
17
            }
18
        };
19

20
        let idx_by = {
2✔
21
            custom_keyword!(by);
22
            input.parse::<by>()?;
2✔
23
            input.parse()?
2✔
24
        };
25

26
        input.parse::<Token![=>]>()?;
2✔
27

28
        let impl_mut = if input.peek(Token![mut]) {
2✔
29
            input.parse::<Token![mut]>()?;
1✔
30
            true
1✔
31
        } else {
32
            false
1✔
33
        };
34

35
        Ok(Self {
36
            impl_mut,
2✔
37
            generics,
2✔
38
            impl_for,
2✔
39
            idx_by,
2✔
40
            output: input.parse()?,
2✔
41
            pairings: {
42
                input.parse::<Token![:]>()?;
2✔
43
                input.parse_terminated(Pairing::parse, Token![,])?
2✔
44
            },
45
        })
46
    }
2✔
47
}
48

49
impl Parse for Pattern {
50
    fn parse(input: ParseStream) -> syn::Result<Self> {
3✔
51
        Ok(Self {
3✔
52
            pat: Pat::parse_multi_with_leading_vert(input)?,
3✔
53
            guard: {
54
                if input.peek(Token![if]) {
3✔
55
                    Some((input.parse()?, input.parse()?))
1✔
56
                } else {
57
                    None
2✔
58
                }
59
            },
60
        })
61
    }
3✔
62
}
63

64
impl<Other: Parse> Parse for MaybeIdent<Other> {
65
    fn parse(input: ParseStream) -> syn::Result<Self> {
10✔
66
        custom_keyword!(pat);
10✔
67

10✔
68
        if input.peek(pat) {
10✔
69
            input.parse::<pat>()?;
4✔
70
            Ok(Self::Other(input.parse()?))
4✔
71
        } else {
72
            Ok(Self::Ident(input.parse()?))
6✔
73
        }
74
    }
10✔
75
}
76

77
impl Parse for Pairing {
78
    fn parse(input: ParseStream) -> syn::Result<Self> {
5✔
79
        Ok(Self {
5✔
80
            enum_variant: input.parse()?,
5✔
81
            struct_field: {
82
                input.parse::<Token![=>]>()?;
5✔
83
                input.parse()?
5✔
84
            },
85
        })
86
    }
5✔
87
}
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