Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 #![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
2 #![allow(
3 clippy::cast_lossless,
4 clippy::manual_range_contains,
5 clippy::match_same_arms,
6 clippy::needless_pass_by_value,
7 clippy::uninlined_format_args,
8 clippy::unnecessary_wraps
9 )]
10 #![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))]
11
12 use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#;
13 use proc_macro2rust-analyzer cargo proc-macro2 1.0.101 crate/::{Identrust-analyzer cargo proc-macro2 1.0.101 Ident#, Literalrust-analyzer cargo proc-macro2 1.0.101 Literal#, Spanrust-analyzer cargo proc-macro2 1.0.101 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.101 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#};
14 use quoterust-analyzer cargo quote 1.0.41 crate/::{quoterust-analyzer cargo quote 1.0.41 quote!, ToTokensrust-analyzer cargo quote 1.0.41 to_tokens/ToTokens#};
15 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
16 use synrust-analyzer cargo syn 2.0.106 crate/::{parse_macro_inputrust-analyzer cargo syn 2.0.106 parse_macro_input/, Errorrust-analyzer cargo syn 2.0.106 error/Error#, Litrust-analyzer cargo syn 2.0.106 lit/Lit#, LitIntrust-analyzer cargo syn 2.0.106 lit/LitInt#, Resultrust-analyzer cargo syn 2.0.106 error/Result#};
17
18 // Branching factor of the MustBeStr tuple type parameter.
19 const Krust-analyzer cargo monostate-impl 1.0.2 K.: usize = 6;
20
21 #[allow(non_snake_case)]
22 #[proc_macro]
23 pub fn MustBerust-analyzer cargo monostate-impl 1.0.2 MustBe!(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
24 let lit = parse_macro_inputrust-analyzer cargo syn 2.0.106 parse_macro_input/parse_macro_input!!(input as Litrust-analyzer cargo syn 2.0.106 lit/Lit#);
25
26 #[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
27 let expanded = match lit {
28 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Strrust-analyzer cargo syn 2.0.106 lit/Lit#Str#(lit) => must_be_strrust-analyzer cargo monostate-impl 1.0.2 must_be_str().(lit.valuerust-analyzer cargo syn 2.0.106 lit/impl#[LitStr]value().()),
29 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Byterust-analyzer cargo syn 2.0.106 lit/Lit#Byte#(lit) => must_be_byterust-analyzer cargo monostate-impl 1.0.2 must_be_byte().(lit.valuerust-analyzer cargo syn 2.0.106 lit/impl#[LitByte]value().()),
30 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Charrust-analyzer cargo syn 2.0.106 lit/Lit#Char#(lit) => must_be_charrust-analyzer cargo monostate-impl 1.0.2 must_be_char().(lit.valuerust-analyzer cargo syn 2.0.106 lit/impl#[LitChar]value().()),
31 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Intrust-analyzer cargo syn 2.0.106 lit/Lit#Int#(lit) => must_be_intrust-analyzer cargo monostate-impl 1.0.2 must_be_int().(lit),
32 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Boolrust-analyzer cargo syn 2.0.106 lit/Lit#Bool#(lit) => must_be_boolrust-analyzer cargo monostate-impl 1.0.2 must_be_bool().(lit.valuerust-analyzer cargo syn 2.0.106 lit/LitBool#value.),
33 Litrust-analyzer cargo syn 2.0.106 lit/Lit#::ByteStrrust-analyzer cargo syn 2.0.106 lit/Lit#ByteStr#(_) | Litrust-analyzer cargo syn 2.0.106 lit/Lit#::CStrrust-analyzer cargo syn 2.0.106 lit/Lit#CStr#(_) | Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Floatrust-analyzer cargo syn 2.0.106 lit/Lit#Float#(_) | Litrust-analyzer cargo syn 2.0.106 lit/Lit#::Verbatimrust-analyzer cargo syn 2.0.106 lit/Lit#Verbatim#(_) => unsupportedrust-analyzer cargo monostate-impl 1.0.2 unsupported().(lit),
34 _ => unsupportedrust-analyzer cargo monostate-impl 1.0.2 unsupported().(lit),
35 };
36
37 expanded.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(Errorrust-analyzer cargo syn 2.0.106 error/Error#::into_compile_errorrust-analyzer cargo syn 2.0.106 error/impl#[Error]into_compile_error().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
38 }
39
40 // We encode the chars at two consecutive levels of a K-ary tree.
41 //
42 // Suppose K=3, then strings "", "a", "ab", "abc", … would be encoded to:
43 // ()
44 // (a)
45 // (a, b)
46 // (a, b, c)
47 // (a, b, (c, d))
48 // (a, b, (c, d, e))
49 // (a, (b, c), (d, e, f))
50 // (a, (b, c, d), (e, f, g))
51 // ((a, b), (c, d, e), (f, g, h))
52 // ((a, b, c), (d, e, f), (g, h, i))
53 // ((a, b, c), (d, e, f), (g, h, (i, j)))
54 // ((a, b, c), (d, e, f), (g, h, (i, j, k)))
55 // ((a, b, c), (d, e, f), (g, (h, i), (j, k l)))
56 //
57 // That last one in tree form is:
58 // ╷
59 // ┌────┴┬──────┐
60 // ┌┴┬─┐ ┌┴┬─┐ ┌─┴┬───┐
61 // a b c d e f g ┌┴┐ ┌┴┬─┐
62 // h i j k l
63
64 enum StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode# {
65 Charrust-analyzer cargo monostate-impl 1.0.2 StrNode#Char#(char),
66 Tuplerust-analyzer cargo monostate-impl 1.0.2 StrNode#Tuple#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#>),
67 }
68
69 impl ToTokensrust-analyzer cargo quote 1.0.41 to_tokens/ToTokens# for StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode# {
70 fn to_tokensrust-analyzer cargo monostate-impl 1.0.2 impl#[StrNode][ToTokens]to_tokens().(&self, tokens: &mut TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#) {
71 tokens.extendrust-analyzer cargo proc-macro2 1.0.101 impl#[TokenStream][`Extend<TokenTree>`]extend().(match self {
72 StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Charrust-analyzer cargo monostate-impl 1.0.2 StrNode#Char#(ch) => {
73 if let 'A'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'Z' | 'a'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'z' = ch {
74 let mut buf = [0];
75 let name = ch.encode_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]encode_utf8().(&mut buf);
76 let ident = Identrust-analyzer cargo proc-macro2 1.0.101 Ident#::newrust-analyzer cargo proc-macro2 1.0.101 impl#[Ident]new().(name, Spanrust-analyzer cargo proc-macro2 1.0.101 Span#::call_siterust-analyzer cargo proc-macro2 1.0.101 impl#[Span]call_site().());
77 quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::alphabet::#ident)
78 } else {
79 match ch.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().() {
80 1 => quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::alphabet::char<#ch>),
81 2 => quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::alphabet::two::char<#ch>),
82 3 => quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::alphabet::three::char<#ch>),
83 4 => quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::alphabet::four::char<#ch>),
84 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
85 }
86 }
87 }
88 StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Tuplerust-analyzer cargo monostate-impl 1.0.2 StrNode#Tuple#(vec) => {
89 let len = vec.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
90 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(len >= 2 && len <= Krust-analyzer cargo monostate-impl 1.0.2 K., "len={}", len);
91 quoterust-analyzer cargo quote 1.0.41 quote!!((#(#vec),*))
92 }
93 });
94 }
95 }
96
97 fn must_be_strrust-analyzer cargo monostate-impl 1.0.2 must_be_str().(value: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
98 if value.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
99 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!! {
100 ::monostate::MustBeStr::<(::monostate::alphabet::len<0>, ())>
101 });
102 }
103 let mut nodes = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
104 for ch in value.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() {
105 nodes.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Charrust-analyzer cargo monostate-impl 1.0.2 StrNode#Char#(ch));
106 }
107 // Find largest power of K smaller than len.
108 let mut pow = 1;
109 while pow rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Krust-analyzer cargo monostate-impl 1.0.2 K. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().nodes.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
110 pow rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign().*=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign().Krust-analyzer cargo monostate-impl 1.0.2 K.;
111 }
112 while nodes.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 {
113 // Number of nodes in excess of the smaller of the two tree levels.
114 let overage = nodes.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().pow;
115 // Every group of K-1 nodes which are beyond the smaller tree level can
116 // be combined with 1 node from the smaller tree level to form a
117 // K-tuple node. The number of tuples that need to be formed is
118 // ceil[overage / (K-1)].
119 let num_tuple_nodes = (overage rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().Krust-analyzer cargo monostate-impl 1.0.2 K. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().(Krust-analyzer cargo monostate-impl 1.0.2 K. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
120 // Number of nodes left needing to be inserted into a tuple.
121 let mut remainder = num_tuple_nodes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().overage;
122 // Index of next node to be inserted into a tuple.
123 let mut read = nodes.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().remainder;
124 // Index of the tuple currently being inserted into.
125 let mut write = read;
126 // True if we haven't yet made a Vec to hold the current tuple.
127 let mut make_tuple = true;
128 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) = nodes.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(read) {
129 let next = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(node, StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Charrust-analyzer cargo monostate-impl 1.0.2 StrNode#Char#('\0'));
130 if make_tuple {
131 nodes[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().write]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Tuplerust-analyzer cargo monostate-impl 1.0.2 StrNode#Tuple#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(Krust-analyzer cargo monostate-impl 1.0.2 K.));
132 }
133 if let StrNoderust-analyzer cargo monostate-impl 1.0.2 StrNode#::Tuplerust-analyzer cargo monostate-impl 1.0.2 StrNode#Tuple#(vec) = &mut nodes[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().write]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). {
134 vec.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next);
135 } else {
136 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!();
137 }
138 remainder rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
139 make_tuple = remainder rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().Krust-analyzer cargo monostate-impl 1.0.2 K. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0;
140 write rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().make_tuple as usize;
141 read rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
142 }
143 nodes.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(pow);
144 pow rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign().Krust-analyzer cargo monostate-impl 1.0.2 K.;
145 }
146 let len = Literalrust-analyzer cargo proc-macro2 1.0.101 Literal#::usize_unsuffixedrust-analyzer cargo proc-macro2 1.0.101 impl#[Literal]usize_unsuffixed().(value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().());
147 let encoded = &nodes[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
148 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!! {
149 ::monostate::MustBeStr::<(::monostate::alphabet::len<#len>, #encoded)>
150 })
151 }
152
153 fn must_be_byterust-analyzer cargo monostate-impl 1.0.2 must_be_byte().(value: u8) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
154 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU8::<#value>))
155 }
156
157 fn must_be_charrust-analyzer cargo monostate-impl 1.0.2 must_be_char().(value: char) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
158 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeChar::<#value>))
159 }
160
161 fn must_be_intrust-analyzer cargo monostate-impl 1.0.2 must_be_int().(lit: LitIntrust-analyzer cargo syn 2.0.106 lit/LitInt#) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
162 let token = lit.tokenrust-analyzer cargo syn 2.0.106 lit/impl#[LitInt]token().();
163 match lit.suffixrust-analyzer cargo syn 2.0.106 lit/impl#[LitInt]suffix().() {
164 "u8" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU8::<#token>)),
165 "u16" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU16::<#token>)),
166 "u32" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU32::<#token>)),
167 "u64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU64::<#token>)),
168 "u128" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeU128::<#token>)),
169 "i8" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeI8::<#token>)),
170 "i16" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeI16::<#token>)),
171 "i32" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeI32::<#token>)),
172 "i64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeI64::<#token>)),
173 "i128" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeI128::<#token>)),
174 "" => {
175 if lit.base10_digitsrust-analyzer cargo syn 2.0.106 lit/impl#[LitInt]base10_digits().().starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('-') {
176 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeNegInt::<#token>))
177 } else {
178 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBePosInt::<#token>))
179 }
180 }
181 suffix @ ("usize" | "isize") => {
182 let msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
183 "serde data model only uses consistently sized integer types, not {}",
184 suffix,
185 );
186 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.106 error/Error#::newrust-analyzer cargo syn 2.0.106 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.106 lit/impl#[LitInt]span().(), msg))
187 }
188 suffix => {
189 let msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("unsupported integers suffix `{}`", suffix);
190 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.106 error/Error#::newrust-analyzer cargo syn 2.0.106 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.106 lit/impl#[LitInt]span().(), msg))
191 }
192 }
193 }
194
195 fn must_be_boolrust-analyzer cargo monostate-impl 1.0.2 must_be_bool().(value: bool) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
196 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.41 quote!!(::monostate::MustBeBool::<#value>))
197 }
198
199 fn unsupportedrust-analyzer cargo monostate-impl 1.0.2 unsupported().(lit: Litrust-analyzer cargo syn 2.0.106 lit/Lit#) -> Resultrust-analyzer cargo syn 2.0.106 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.101 TokenStream#> {
200 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.106 error/Error#::newrust-analyzer cargo syn 2.0.106 error/impl#[Error]new().(lit.spanrust-analyzer cargo syn 2.0.106 lit/value/impl#[Lit]span().(), "unsupported monostate literal kind"))
201 }