Debian Codegraph @

src/format.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::{TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#, TryIntorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#};
2
3 use regexrust-analyzer cargo regex 1.12.3 crate/::Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#;
4 use smol_strrust-analyzer cargo smol_str 0.1.24 crate/::SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#;
5 use unicode_segmentationrust-analyzer cargo unicode-segmentation 1.12.0 crate/::UnicodeSegmentationrust-analyzer cargo unicode-segmentation 1.12.0 UnicodeSegmentation#;
6
7 use craterust-analyzer cargo git-delta 0.19.2 crate/::featuresrust-analyzer cargo git-delta 0.19.2 features/::side_by_siderust-analyzer cargo git-delta 0.19.2 features/side_by_side/::ansifillrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/::ODD_PAD_CHARrust-analyzer cargo git-delta 0.19.2 features/side_by_side/ansifill/ODD_PAD_CHAR.;
8
9 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
10 pub enum Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#<'a> {
11 NumberMinusrust-analyzer cargo git-delta 0.19.2 format/Placeholder#NumberMinus#,
12 NumberPlusrust-analyzer cargo git-delta 0.19.2 format/Placeholder#NumberPlus#,
13 Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#(&'a str),
14 }
15
16 impl<'a> TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>> for Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#<'a> {
17 type Errorrust-analyzer cargo git-delta 0.19.2 format/impl#[`Placeholder<'a>`][`TryFrom<Option<&'a str>>`]Error# = ();
18 fn try_fromrust-analyzer cargo git-delta 0.19.2 format/impl#[`Placeholder<'a>`][`TryFrom<Option<&'a str>>`]try_from().(from: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`Placeholder<'a>`][`TryFrom<Option<&'a str>>`], Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`Placeholder<'a>`][`TryFrom<Option<&'a str>>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
19 match from {
20 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("nm") => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::NumberMinusrust-analyzer cargo git-delta 0.19.2 format/Placeholder#NumberMinus#),
21 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("np") => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::NumberPlusrust-analyzer cargo git-delta 0.19.2 format/Placeholder#NumberPlus#),
22 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(placeholder) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#(placeholder)),
23 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()),
24 }
25 }
26 }
27
28 #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
29 pub enum Alignrust-analyzer cargo git-delta 0.19.2 format/Align# {
30 Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#,
31 Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#,
32 Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right#,
33 }
34
35 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>> for Alignrust-analyzer cargo git-delta 0.19.2 format/Align# {
36 type Errorrust-analyzer cargo git-delta 0.19.2 format/impl#[Align][`TryFrom<Option<&str>>`]Error# = ();
37 fn try_fromrust-analyzer cargo git-delta 0.19.2 format/impl#[Align][`TryFrom<Option<&str>>`]try_from().(from: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[Align][`TryFrom<Option<&str>>`], Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[Align][`TryFrom<Option<&str>>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
38 // inlined format args are not supported for `debug_assert` with edition 2018.
39 #[allow(clippy::uninlined_format_args)]
40 match from {
41 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("<") => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
42 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(">") => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right#),
43 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("^") => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#),
44 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(alignment) => {
45 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(false, "Unknown Alignment: {}", alignment);
46 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(())
47 }
48 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()),
49 }
50 }
51 }
52
53 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
54 pub struct FormatStringPlaceholderDataAnyPlaceholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#<T> {
55 pub prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#,
56 pub prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: usize,
57 pub placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T>,
58 pub alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Alignrust-analyzer cargo git-delta 0.19.2 format/Align#>,
59 pub widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
60 pub precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
61 pub fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#,
62 pub suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#,
63 pub suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: usize,
64 }
65
66 impl<T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for FormatStringPlaceholderDataAnyPlaceholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#<T> {
67 fn defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().() -> Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default] {
68 Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default] {
69 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
70 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 0,
71 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
72 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
73 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
74 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
75 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
76 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
77 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 0,
78 }
79 }
80 }
81
82 impl<T> FormatStringPlaceholderDataAnyPlaceholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#<T> {
83 pub fn only_stringrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`]only_string().(s: &str) -> Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`] {
84 Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`] {
85 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: s.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
86 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: s.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(),
87 ..Selfrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`]::defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().()
88 }
89 }
90 }
91
92 pub type FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData#<'a> =
93 FormatStringPlaceholderDataAnyPlaceholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#<Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#<'a>>;
94
95 pub type FormatStringSimplerust-analyzer cargo git-delta 0.19.2 format/FormatStringSimple# = FormatStringPlaceholderDataAnyPlaceholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#<()>;
96
97 impl FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData#<'_> {
98 pub fn widthrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<Placeholder<'_>>`]width().(&self, hunk_max_line_number_width: usize) -> (usize, usize) {
99 // Only if Some(placeholder) is present will there be a number formatted
100 // by this placeholder, if not width is also None.
101 (
102 self.prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.
103 +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().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(
104 self.placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.
105 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
106 .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(0, |_| hunk_max_line_number_width),
107 self.widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width..unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0),
108 ),
109 self.suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.,
110 )
111 }
112 pub fn into_simplerust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<Placeholder<'_>>`]into_simple().(self) -> FormatStringSimplerust-analyzer cargo git-delta 0.19.2 format/FormatStringSimple# {
113 FormatStringSimplerust-analyzer cargo git-delta 0.19.2 format/FormatStringSimple# {
114 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: self.prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.,
115 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: self.prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.,
116 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
117 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: self.alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.,
118 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: self.widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.,
119 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: self.precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.,
120 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: self.fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.,
121 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: self.suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.,
122 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: self.suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.,
123 }
124 }
125 }
126
127 pub type FormatStringDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringData#<'a> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData#<'a>>;
128
129 pub fn make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(labels: &[&str]) -> Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex# {
130 Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#::newrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]new().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
131 r"(?x)
132 \{{
133 ({}) # 1: Placeholder labels
134 (?: # Start optional format spec (non-capturing)
135 : # Literal colon
136 (?: # Start optional fill/alignment spec (non-capturing)
137 ([^<^>])? # 2: Optional fill character (ignored)
138 ([<^>]) # 3: Alignment spec
139 )? #
140 (\d+)? # 4: Width (optional)
141 (?: # Start optional precision (non-capturing)
142 \.(\d+) # 5: Precision
143 )? #
144 (?: # Start optional format type (non-capturing)
145 _?([A-Za-z][0-9A-Za-z_-]*) # 6: Format type, optional leading _
146 )? #
147 )? #
148 \}}
149 ",
150 labels.joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("|")
151 ))
152 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
153 }
154
155 // The resulting vector is never empty
156 pub fn parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().<'a>(
157 format_string: &'a str,
158 placeholder_regex: &Regexrust-analyzer cargo regex 1.12.3 regex/string/Regex#,
159 mut prefix_with_space: bool,
160 ) -> FormatStringDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringData#<'a> {
161 let mut format_data = 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().();
162 let mut offset = 0;
163
164 let mut expand_first_prefix = |prefix: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#| {
165 // Only prefix the first placeholder with a space, also see `UseFullPanelWidth`
166 if prefix_with_space {
167 let prefix = SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::newrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{ODD_PAD_CHAR}{prefix}"));
168 prefix_with_space = false;
169 prefix
170 } else {
171 prefix
172 }
173 };
174
175 for captures in placeholder_regex.captures_iterrust-analyzer cargo regex 1.12.3 regex/string/impl#[Regex]captures_iter().(format_string) {
176 let match_ = captures.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
177 let prefix = SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::newrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr]new().(&format_string[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#match_.startrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
178 let prefix = expand_first_prefix(prefix);
179 let prefix_len = prefix.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
180 let suffix = SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::newrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr]new().(&format_string[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().match_.endrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]end().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
181 let suffix_len = suffix.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
182 format_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
183 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.,
184 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.,
185 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: captures.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(1).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|m| m.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(),
186 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: captures.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(3).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|m| m.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(),
187 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: captures.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(4).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|m| {
188 m.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()
189 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
190 .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Invalid width in format string: {}", format_string))
191 }),
192 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: captures.getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(5).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|m| {
193 m.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| {
194 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Invalid precision in format string: {}", format_string)
195 })
196 }),
197 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: captures
198 .getrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Captures<'h>`]get().(6)
199 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|m| SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::fromrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][`From<T>`]from().(m.as_strrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]as_str().()))
200 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(),
201 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.,
202 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.,
203 });
204 offset = match_.endrust-analyzer cargo regex 1.12.3 regex/string/impl#[`Match<'h>`]end().();
205 }
206 if offset 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 {
207 let prefix = SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::newrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr]new().("");
208 let prefix = expand_first_prefix(prefix);
209 let prefix_len = prefix.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().();
210 // No placeholders
211 format_data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
212 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.,
213 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.,
214 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::newrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr]new().(format_string),
215 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: format_string.graphemesrust-analyzer cargo unicode-segmentation 1.12.0 impl#[str][UnicodeSegmentation]graphemes().(true).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(),
216 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().()
217 })
218 }
219
220 format_data
221 }
222
223 pub trait CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers# {
224 // There is no such thing as "Center Align" with discrete terminal cells. In
225 // some cases a decision has to be made whether to use the left or the right
226 // cell, e.g. when centering one char in 4 cells: "_X__" or "__X_".
227 //
228 // The format!() center/^ default is center left, but when padding numbers
229 // these are now aligned to the center right by having this trait return " "
230 // instead of "". This is prepended to the format string. In the case of " "
231 // the trailing " " must then be removed so everything is shifted to the right.
232 // This assumes no special padding characters, i.e. the default of space.
233 fn center_right_spacerust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers#center_right_space().(&self, alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#, width: usize) -> &'static str;
234 }
235
236 impl CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers# for &str {
237 fn center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&str`][CenterRightNumbers]center_right_space().(&self, _alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#, _width: usize) -> &'static str {
238 // Disables center-right formatting and aligns strings center-left
239 ""
240 }
241 }
242
243 impl CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers# for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
244 fn center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[String][CenterRightNumbers]center_right_space().(&self, alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#, width: usize) -> &'static str {
245 self.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().().center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&str`][CenterRightNumbers]center_right_space().(alignment, width)
246 }
247 }
248
249 impl CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers# for &stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str> {
250 fn center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&std::borrow::Cow<'_, str>`][CenterRightNumbers]center_right_space().(&self, alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#, width: usize) -> &'static str {
251 self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`&T`][`AsRef<U>`]as_ref().().center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&str`][CenterRightNumbers]center_right_space().(alignment, width)
252 }
253 }
254
255 // Returns the base-10 width of `n`, i.e. `floor(log10(n)) + 1` and 0 is treated as 1.
256 pub fn log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/log10_plus_1().(mut n: usize) -> usize {
257 let mut len = 0;
258 // log10 for integers is only in nightly and this is faster than
259 // casting to f64 and back.
260 loop {
261 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().9 {
262 break len 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;
263 }
264 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().99 {
265 break len 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;
266 }
267 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().999 {
268 break len 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().3;
269 }
270 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().9999 {
271 break len 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().4;
272 }
273
274 len 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().4;
275 n 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().10000;
276 }
277 }
278
279 impl CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers# for usize {
280 fn center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[usize][CenterRightNumbers]center_right_space().(&self, alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#, width: usize) -> &'static str {
281 if alignment rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center# {
282 return "";
283 }
284
285 let width_of_number = log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/log10_plus_1().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self);
286 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().width_of_number && (width 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().width_of_number 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) {
287 " "
288 } else {
289 ""
290 }
291 }
292 }
293
294 // Note that in this case of a string `s`, `precision` means "max width".
295 // See https://doc.rust-lang.org/std/fmt/index.html
296 pub fn padrust-analyzer cargo git-delta 0.19.2 format/pad().<T: 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/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + CenterRightNumbersrust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers#>(
297 s: T,
298 width: usize,
299 alignment: Alignrust-analyzer cargo git-delta 0.19.2 format/Align#,
300 precision: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
301 ) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
302 let space = s.center_right_spacerust-analyzer cargo git-delta 0.19.2 format/CenterRightNumbers#center_right_space().(alignment, width);
303 let mut result = match precision {
304 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => match alignment {
305 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:<width$}"),
306 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:^width$}"),
307 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:>width$}"),
308 },
309 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(precision) => match alignment {
310 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:<width$.precision$}"),
311 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:^width$.precision$}"),
312 Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{space}{s:>width$.precision$}"),
313 },
314 };
315 if space 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()." " {
316 result.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]pop().();
317 }
318 result
319 }
320
321 #[cfg(test)]
322 mod testsrust-analyzer cargo git-delta 0.19.2 format/tests/ {
323 use superrust-analyzer cargo git-delta 0.19.2 format/::*;
324
325 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
326 fn test_log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/tests/test_log10_plus_1().() {
327 let nrs = [
328 1, 9, 10, 11, 99, 100, 101, 999, 1_000, 1_001, 9_999, 10_000, 10_001, 99_999, 100_000,
329 100_001, 0,
330 ];
331 let widths = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 1];
332 for (n, w) in nrs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(widths.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) {
333 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/log10_plus_1().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().n), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().w);
334 }
335
336 #[cfg(target_pointer_width = "64")]
337 {
338 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/log10_plus_1().(744_073_709_551_615), 5 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 3);
339 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(log10_plus_1rust-analyzer cargo git-delta 0.19.2 format/log10_plus_1().(18_446_744_073_709_551_615), 2 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 6 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 3);
340 }
341 }
342
343 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
344 fn test_center_right_space_traitrust-analyzer cargo git-delta 0.19.2 format/tests/test_center_right_space_trait().() {
345 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("abc".center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&str`][CenterRightNumbers]center_right_space().(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, 6), "");
346 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("abc".center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[`&str`][CenterRightNumbers]center_right_space().(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, 7), "");
347 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(123.center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[usize][CenterRightNumbers]center_right_space().(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, 6), " ");
348 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(123.center_right_spacerust-analyzer cargo git-delta 0.19.2 format/impl#[usize][CenterRightNumbers]center_right_space().(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, 7), "");
349 }
350
351 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
352 fn test_pad_center_alignrust-analyzer cargo git-delta 0.19.2 format/tests/test_pad_center_align().() {
353 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().("abc", 6, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " abc ");
354 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 1, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), "1");
355 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 2, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " 1");
356 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 3, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " 1 ");
357 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 4, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " 1 ");
358
359 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1001, 3, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), "1001");
360 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1001, 4, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), "1001");
361 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1001, 5, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " 1001");
362
363 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 4, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), "1 ");
364 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().(1, 4, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " 1");
365 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().("abc", 5, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), "abc ");
366 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(padrust-analyzer cargo git-delta 0.19.2 format/pad().("abc", 5, Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Rightrust-analyzer cargo git-delta 0.19.2 format/Align#Right#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), " abc");
367 }
368
369 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
370 fn test_placeholder_with_notyperust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_with_notype().() {
371 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["placeholder"]);
372 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
373 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("{placeholder:^4}", &regex, false),
374 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
375 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
376 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Centerrust-analyzer cargo git-delta 0.19.2 format/Align#Center#),
377 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4),
378 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().()
379 }]
380 );
381 }
382
383 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
384 fn test_placeholder_with_only_type_dash_numberrust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_with_only_type_dash_number().() {
385 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["placeholder"]);
386 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
387 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("{placeholder:a_type-b-12}", &regex, false),
388 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
389 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
390 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: "a_type-b-12".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
391 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().()
392 }]
393 );
394 }
395
396 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
397 fn test_placeholder_with_empty_formattingrust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_with_empty_formatting().() {
398 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["placeholder"]);
399 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
400 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("{placeholder:}", &regex, false),
401 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
402 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
403 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`][Default]default().()
404 }]
405 );
406 }
407
408 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
409 fn test_placeholder_with_type_and_morerust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_with_type_and_more().() {
410 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["placeholder"]);
411 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
412 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("prefix {placeholder:<15.14type} suffix", &regex, false),
413 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
414 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
415 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
416 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
417 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
418 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
419 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: "type".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
420 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
421 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
422 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
423 }]
424 );
425
426 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
427 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("prefix {placeholder:<15.14_type} suffix", &regex, false),
428 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
429 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
430 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
431 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
432 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
433 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
434 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: "type".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
435 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
436 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
437 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
438 }]
439 );
440 }
441
442 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
443 fn test_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_regex().() {
444 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["placeholder"]);
445 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
446 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("prefix {placeholder:<15.14} suffix", &regex, false),
447 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
448 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
449 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("placeholder")),
450 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
451 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
452 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
453 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
454 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
455 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
456 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
457 }]
458 );
459 }
460
461 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
462 fn test_placeholder_regex_empty_placeholderrust-analyzer cargo git-delta 0.19.2 format/tests/test_placeholder_regex_empty_placeholder().() {
463 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&[""]);
464 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
465 parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("prefix {:<15.14} suffix", &regex, false),
466 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
467 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
468 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("")),
469 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
470 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
471 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
472 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
473 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
474 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
475 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
476 }]
477 );
478 }
479 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
480 fn test_format_string_simplerust-analyzer cargo git-delta 0.19.2 format/tests/test_format_string_simple().() {
481 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["foo"]);
482 let f = parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("prefix {foo:<15.14} suffix", &regex, false);
483
484 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
485 f,
486 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData# {
487 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
488 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Placeholderrust-analyzer cargo git-delta 0.19.2 format/Placeholder#::Strrust-analyzer cargo git-delta 0.19.2 format/Placeholder#Str#("foo")),
489 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
490 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
491 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
492 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
493 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
494 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
495 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
496 }]
497 );
498 let simple: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = f
499 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
500 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(FormatStringPlaceholderDatarust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderData#::into_simplerust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<Placeholder<'_>>`]into_simple().)
501 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
502 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
503 simple,
504 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![FormatStringSimplerust-analyzer cargo git-delta 0.19.2 format/FormatStringSimple# {
505 prefixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix.: "prefix ".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
506 placeholderrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#placeholder.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
507 alignment_specrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#alignment_spec.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Alignrust-analyzer cargo git-delta 0.19.2 format/Align#::Leftrust-analyzer cargo git-delta 0.19.2 format/Align#Left#),
508 widthrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#width.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(15),
509 precisionrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#precision.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(14),
510 fmt_typerust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#fmt_type.: SmolStrrust-analyzer cargo smol_str 0.1.24 SmolStr#::defaultrust-analyzer cargo smol_str 0.1.24 impl#[SmolStr][Default]default().(),
511 suffixrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix.: " suffix".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
512 prefix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#prefix_len.: 7,
513 suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len.: 7,
514 }]
515 );
516 }
517
518 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
519 fn test_line_number_format_only_stringrust-analyzer cargo git-delta 0.19.2 format/tests/test_line_number_format_only_string().() {
520 let f = FormatStringSimplerust-analyzer cargo git-delta 0.19.2 format/FormatStringSimple#::only_stringrust-analyzer cargo git-delta 0.19.2 format/impl#[`FormatStringPlaceholderDataAnyPlaceholder<T>`]only_string().("abc");
521 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.suffix_lenrust-analyzer cargo git-delta 0.19.2 format/FormatStringPlaceholderDataAnyPlaceholder#suffix_len., 3);
522 }
523
524 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
525 fn test_parse_line_number_format_not_emptyrust-analyzer cargo git-delta 0.19.2 format/tests/test_parse_line_number_format_not_empty().() {
526 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&["abc"]);
527 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().(" abc ", &regex, false).is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
528 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("", &regex, false).is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
529 let regex = make_placeholder_regexrust-analyzer cargo git-delta 0.19.2 format/make_placeholder_regex().(&[""]);
530 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().(" abc ", &regex, false).is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
531 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().parse_line_number_formatrust-analyzer cargo git-delta 0.19.2 format/parse_line_number_format().("", &regex, false).is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
532 }
533 }