Debian Codegraph @

src/format_spec.rs

raw symbols SCIP
1 use craterust-analyzer cargo formatx 0.2.4 crate/::errorrust-analyzer cargo formatx 0.2.4 error/::Errorrust-analyzer cargo formatx 0.2.4 error/Error#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#};
3
4 macro_rules! parserust-analyzer cargo formatx 0.2.4 format_spec/parse! {
5 ($($arg:tt)*) => {
6 return Err($crate::error::Error::new_parse(format!($($arg)*)))
7 };
8 }
9
10 macro_rules! ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs! {
11 ($($arg:tt)*) => {
12 return Err($crate::error::Error::new_ufs(format!($($arg)*)))
13 };
14 }
15
16 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
17 pub struct FormatSpecrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec# {
18 alignrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#align.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>,
19 signrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#sign.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
20 hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag.: bool,
21 zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero.: bool,
22 widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
23 precisionrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#precision.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
24 typesrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#types.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
25 }
26
27 impl FormatSpecrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec# {
28 pub(craterust-analyzer cargo formatx 0.2.4 crate/) fn newrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]new().(placeholder: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec], Errorrust-analyzer cargo formatx 0.2.4 error/Error#> {
29 if placeholder.rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rfind().(':').is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
30 let spec = placeholder.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(':').lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
31 Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]::validaterust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]validate().(spec.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), placeholder)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
32 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]::parserust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]parse().(spec));
33 }
34
35 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]::defaultrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec][Default]default().())
36 }
37
38 fn validaterust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]validate().(mut spec: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, placeholder: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo formatx 0.2.4 error/Error#> {
39 let mut align_index = match (spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('<'), spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('^'), spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('>')) {
40 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
41 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(left), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(left),
42 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(center), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(center),
43 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(right)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(right),
44 _ => parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!("multiple align specifiers used in {{{}}}", placeholder),
45 };
46
47 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = align_index {
48 if x 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().1 {
49 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().((x 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)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#x, "");
50 align_index = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(0);
51 }
52 }
53
54 let sign_index = match (spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('+'), spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('-')) {
55 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
56 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(positive), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(positive),
57 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(negative)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(negative),
58 _ => parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!("multiple signs used in {{{}}}", placeholder),
59 };
60
61 let hashtag_index = spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('#');
62 let mut zero_index = spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('0');
63 let precision_index = spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('.');
64
65 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = zero_index {
66 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(y) = precision_index {
67 if x 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().y {
68 zero_index = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
69 }
70 }
71 }
72
73 let question_index = spec.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('?');
74
75 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = align_index {
76 for (spec_name, spec_index) in [
77 ("sign", sign_index),
78 ("#", hashtag_index),
79 ("0 padding and width", zero_index),
80 ("precision", precision_index),
81 ("?", question_index),
82 ]
83 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
84 {
85 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_index) = spec_index {
86 if x 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().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec_index {
87 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
88 "align should be used before {} in {{{}}}",
89 spec_name,
90 placeholder
91 );
92 }
93 }
94 }
95 }
96
97 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = sign_index {
98 for (spec_name, spec_index) in [
99 ("#", hashtag_index),
100 ("0 padding and width", zero_index),
101 ("precision", precision_index),
102 ("?", question_index),
103 ]
104 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
105 {
106 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_index) = spec_index {
107 if x 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().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec_index {
108 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
109 "sign should be used before {} in {{{}}}",
110 spec_name,
111 placeholder
112 );
113 }
114 }
115 }
116 }
117
118 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = hashtag_index {
119 for (spec_name, spec_index) in [
120 ("0 padding and width", zero_index),
121 ("precision", precision_index),
122 ("?", question_index),
123 ]
124 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
125 {
126 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_index) = spec_index {
127 if x 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().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec_index {
128 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
129 "# should be used before {} in {{{}}}",
130 spec_name,
131 placeholder
132 );
133 }
134 }
135 }
136 }
137
138 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = zero_index {
139 for (spec_name, spec_index) in
140 [("precision", precision_index), ("?", question_index)].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
141 {
142 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_index) = spec_index {
143 if x 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().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec_index {
144 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
145 "0 should be used before {} in {{{}}}",
146 spec_name,
147 placeholder
148 );
149 }
150 }
151 }
152 }
153
154 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = precision_index {
155 for (spec_name, spec_index) in [("?", question_index)].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
156 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_index) = spec_index {
157 if x 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().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec_index {
158 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
159 "precision should be used before {} in {{{}}}",
160 spec_name,
161 placeholder
162 );
163 }
164 }
165 }
166
167 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(y) = spec.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().((x 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().1)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(x 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().2)) {
168 if y.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<usize>().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
169 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!(
170 "precision value is not a valid usize in {{{}}}",
171 placeholder
172 );
173 }
174 } else {
175 parserust-analyzer cargo formatx 0.2.4 format_spec/parse!!("precision value not supplied in {{{}}}", placeholder);
176 }
177 }
178
179 // UNSUPPORTED FORMAT SPECS
180
181 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('$') {
182 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
183 "parameter setting through $ sign argument is not supported but used in {{{}}}",
184 placeholder
185 );
186 }
187
188 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(".*") {
189 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
190 "asterisk .* formatting is not supported but used in {{{}}}",
191 placeholder
192 );
193 }
194
195 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('o') {
196 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
197 "o formatting is not supported but used in {{{}}}",
198 placeholder
199 );
200 }
201
202 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('x') {
203 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
204 "x formatting is not supported but used in {{{}}}",
205 placeholder
206 );
207 }
208
209 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('X') {
210 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
211 "X formatting is not supported but used in {{{}}}",
212 placeholder
213 );
214 }
215
216 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('p') {
217 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
218 "p formatting is not supported but used in {{{}}}",
219 placeholder
220 );
221 }
222
223 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('b') {
224 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
225 "b formatting is not supported but used in {{{}}}",
226 placeholder
227 );
228 }
229
230 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('e') {
231 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
232 "e formatting is not supported but used in {{{}}}",
233 placeholder
234 );
235 }
236
237 if spec.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('E') {
238 ufsrust-analyzer cargo formatx 0.2.4 format_spec/ufs!!(
239 "E formatting is not supported but used in {{{}}}",
240 placeholder
241 );
242 }
243
244 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
245 }
246
247 fn parserust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]parse().(mut spec: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec] {
248 let spec_copy = spec.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().();
249 let align = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(align) = spec_copy.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
250 if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."<" || align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."^" || align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().">" {
251 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1, "");
252 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, align.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))
253 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(align) = spec_copy.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2) {
254 if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."<" || align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."^" || align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().">" {
255 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2, "");
256 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
257 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec_copy.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),
258 align.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
259 ))
260 } else {
261 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
262 }
263 } else {
264 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
265 }
266 } else {
267 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
268 };
269
270 let spec_copy = spec.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().();
271 let sign = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sign) = spec_copy.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
272 if sign rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."+" || sign rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."-" {
273 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1, "");
274 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sign.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())
275 } else {
276 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
277 }
278 } else {
279 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
280 };
281
282 let hashtag = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hastag) = spec.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
283 if hastag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."#" {
284 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1, "");
285 true
286 } else {
287 false
288 }
289 } else {
290 false
291 };
292
293 let zero = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(zero) = spec.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
294 if zero rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."0" {
295 spec.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1, "");
296 true
297 } else {
298 false
299 }
300 } else {
301 false
302 };
303
304 let width = craterust-analyzer cargo formatx 0.2.4 crate/::utilsrust-analyzer cargo formatx 0.2.4 utils/::usize_tokenrust-analyzer cargo formatx 0.2.4 utils/usize_token().(&spec, 0);
305
306 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = width {
307 spec = spec.trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().(&x.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
308 }
309
310 let precision = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(point) = spec.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
311 if point rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."." {
312 craterust-analyzer cargo formatx 0.2.4 crate/::utilsrust-analyzer cargo formatx 0.2.4 utils/::usize_tokenrust-analyzer cargo formatx 0.2.4 utils/usize_token().(&spec, 1)
313 } else {
314 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
315 }
316 } else {
317 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
318 };
319
320 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = precision {
321 spec = spec.trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(".{}", x)).to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
322 }
323
324 let types = if spec.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
325 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
326 } else {
327 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(spec.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(' ').nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())
328 };
329
330 Selfrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec] {
331 alignrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#align.,
332 signrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#sign.,
333 hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag.,
334 zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero.,
335 widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width.,
336 precisionrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#precision.,
337 typesrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#types.,
338 }
339 }
340
341 pub fn formatrust-analyzer cargo formatx 0.2.4 format_spec/impl#[FormatSpec]format().<T: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#>(&self, value: T) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
342 let mut fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", value);
343
344 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(precision) = self.precisionrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#precision. {
345 if self.zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero. && self.hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag. {
346 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#0.1$}", value, precision);
347 } else if self.hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag. {
348 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#.1$}", value, precision);
349 } else {
350 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:.1$}", value, precision);
351 }
352 }
353
354 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(types) = &self.typesrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#types. {
355 if self.hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag. {
356 if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."?" {
357 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#?}", value);
358 } else if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."x?" {
359 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#x?}", value);
360 } else if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."X?" {
361 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#X?}", value);
362 }
363 } else if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."?" {
364 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", value);
365 } else if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."x?" {
366 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x?}", value);
367 } else if types rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."X?" {
368 return formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X?}", value);
369 }
370 }
371
372 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sign) = &self.signrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#sign. {
373 if sign rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."+" && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero. && craterust-analyzer cargo formatx 0.2.4 crate/::utilsrust-analyzer cargo formatx 0.2.4 utils/::is_number_and_positiverust-analyzer cargo formatx 0.2.4 utils/is_number_and_positive().(&fmtval) {
374 fmtval = "+".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval;
375 }
376 }
377
378 match &self.alignrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#align. {
379 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fill), align)) => {
380 fmtval = fmtval.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
381 let chars_count = fmtval.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]count().();
382 let width = self.widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0);
383
384 if width 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().chars_count {
385 if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."<" {
386 fmtval = fmtval rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fill.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count);
387 } else if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."^" {
388 let factor = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<bool>`]from().(chars_count 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().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0);
389 let start = fill.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().((width 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().chars_count 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().factor) 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().2);
390 let end = fill.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().((width 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().chars_count 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().factor) 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().2);
391 fmtval = start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&end;
392 } else if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().">" {
393 fmtval = fill.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval;
394 }
395 }
396 }
397 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, align)) => {
398 if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."<" {
399 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:<1$}", fmtval, self.widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0));
400 } else if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."^" {
401 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:^1$}", fmtval, self.widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0));
402 } else if align rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().">" {
403 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:>1$}", fmtval, self.widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0));
404 }
405 }
406 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (),
407 }
408
409 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(width) = self.widthrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#width. {
410 if craterust-analyzer cargo formatx 0.2.4 crate/::utilsrust-analyzer cargo formatx 0.2.4 utils/::is_numberrust-analyzer cargo formatx 0.2.4 utils/is_number().(&fmtval) {
411 let chars_count = fmtval.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]count().();
412
413 if self.zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero. && width 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().chars_count {
414 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sign) = &self.signrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#sign. {
415 if sign rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."+" {
416 if craterust-analyzer cargo formatx 0.2.4 crate/::utilsrust-analyzer cargo formatx 0.2.4 utils/::is_number_and_positiverust-analyzer cargo formatx 0.2.4 utils/is_number_and_positive().(&fmtval) {
417 fmtval =
418 "+".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count 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) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval;
419 } else {
420 fmtval = "-".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()
421 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count)
422 +rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().&fmtval[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
423 }
424 } else if sign rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."-" {
425 fmtval =
426 "-".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count) rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().&fmtval[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
427 }
428 } else if fmtval.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('-') {
429 fmtval = "-".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&"0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count) rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().&fmtval[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
430 } else {
431 fmtval = "0".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval;
432 }
433 } else if width 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().chars_count {
434 fmtval = " ".repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width 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().chars_count) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&fmtval;
435 }
436 } else if self.zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero. && self.hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag. {
437 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#01$}", fmtval, width);
438 } else if self.zerorust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#zero. {
439 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:01$}", fmtval, width);
440 } else if self.hashtagrust-analyzer cargo formatx 0.2.4 format_spec/FormatSpec#hashtag. {
441 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:#1$}", fmtval, width);
442 } else {
443 fmtval = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:1$}", fmtval, width);
444 }
445 }
446
447 fmtval
448 }
449 }