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 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::{CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#, CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#};
3
4 use craterust-analyzer cargo sprintf 0.4.2 crate/::{
5 parserrust-analyzer cargo sprintf 0.4.2 parser/::{ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#, ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#, NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#},
6 PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#, Resultrust-analyzer cargo sprintf 0.4.2 Result#,
7 };
8
9 /// Trait for types that can be formatted using printf strings
10 ///
11 /// Implemented for the basic types and shouldn't need implementing for
12 /// anything else.
13 pub trait Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# {
14 /// Format `self` based on the conversion configured in `spec`.
15 fn formatrust-analyzer cargo sprintf 0.4.2 format/Printf#format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>;
16 /// Get `self` as an integer for use as a field width, if possible.
17 fn as_intrust-analyzer cargo sprintf 0.4.2 format/Printf#as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32>;
18 }
19
20 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for u64 {
21 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
22 let mut base = 10;
23 let mut digits: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = "0123456789".charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
24 let mut alt_prefix = "";
25 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
26 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecInt# => {}
27 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntLower# => {
28 base = 16;
29 digits = "0123456789abcdef".charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
30 alt_prefix = "0x";
31 }
32 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntUpper# => {
33 base = 16;
34 digits = "0123456789ABCDEF".charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
35 alt_prefix = "0X";
36 }
37 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::OctIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#OctInt# => {
38 base = 8;
39 digits = "01234567".charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
40 alt_prefix = "0";
41 }
42 _ => {
43 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#);
44 }
45 }
46 let prefix = if spec.alt_formrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#alt_form. {
47 alt_prefix.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()
48 } else {
49 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().()
50 };
51
52 // Build the actual number (in reverse)
53 let mut rev_num = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
54 let mut n = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self;
55 while n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 {
56 let digit = n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().base;
57 n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign().base;
58 rev_num.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(digits[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().digit as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().);
59 }
60 if rev_num.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
61 rev_num.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('0');
62 }
63
64 // Take care of padding
65 let width: usize = match spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. {
66 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w) => w,
67 _ => {
68 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#); // should not happen at this point!!
69 }
70 }
71 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()
72 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_default().();
73 let formatted = if spec.left_adjrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#left_adj. {
74 let mut num_str = prefix 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().&rev_num.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>();
75 while num_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
76 num_str.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
77 }
78 num_str
79 } else if spec.zero_padrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#zero_pad. {
80 while prefix.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().rev_num.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
81 rev_num.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('0');
82 }
83 prefix 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().&rev_num.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()
84 } else {
85 let mut num_str = prefix 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().&rev_num.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>();
86 while num_str.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
87 num_str = " ".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().&num_str;
88 }
89 num_str
90 };
91
92 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(formatted)
93 }
94 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
95 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`TryFrom<u64>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
96 }
97 }
98
99 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for i64 {
100 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i64][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
101 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
102 // signed integer format
103 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecInt# => {
104 // do I need a sign prefix?
105 let negative = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().0;
106 let abs_val = self.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]abs().();
107 let sign_prefix = if negative {
108 "-"
109 } else if spec.force_signrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#force_sign. {
110 "+"
111 } else if spec.space_signrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#space_sign. {
112 " "
113 } else {
114 ""
115 }
116 .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
117 let mut mod_spec = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().spec;
118 mod_spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. = match spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. {
119 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w) => NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().sign_prefix.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() as i32),
120 _ => {
121 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#);
122 }
123 };
124
125 let formatted = (abs_val as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(&mod_spec)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
126 // put the sign a after any leading spaces
127 let mut actual_number = &formatted[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().0..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().;
128 let mut leading_spaces = &formatted[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
129 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first_non_space) = formatted.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]ne().' ') {
130 actual_number = &formatted[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().first_non_space..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().;
131 leading_spaces = &formatted[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#first_non_space]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().;
132 }
133 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(leading_spaces.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().&sign_prefix 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().actual_number)
134 }
135 // unsigned-only formats
136 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntUpper# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::OctIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#OctInt# => {
137 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec)
138 }
139 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#),
140 }
141 }
142 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[i64][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
143 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`TryFrom<i64>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
144 }
145 }
146
147 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for i32 {
148 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i32][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
149 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
150 // signed integer format
151 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecInt# => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i64][Printf]format().(spec),
152 // unsigned-only formats
153 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntUpper# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::OctIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#OctInt# => {
154 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u32).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u32][Printf]format().(spec)
155 }
156 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#),
157 }
158 }
159 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[i32][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
160 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self)
161 }
162 }
163
164 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for u32 {
165 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u32][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
166 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
167 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Charrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#Char# => {
168 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = char::from_u32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]from_u32().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self) {
169 c.formatrust-analyzer cargo sprintf 0.4.2 format/impl#[char][Printf]format().(spec)
170 } else {
171 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
172 }
173 }
174 _ => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec),
175 }
176 }
177 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[u32][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
178 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`TryFrom<u32>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
179 }
180 }
181
182 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for i16 {
183 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i16][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
184 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
185 // signed integer format
186 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecInt# => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i64][Printf]format().(spec),
187 // unsigned-only formats
188 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntUpper# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::OctIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#OctInt# => {
189 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u16).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u16][Printf]format().(spec)
190 }
191 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#),
192 }
193 }
194 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[i16][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
195 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i32)
196 }
197 }
198
199 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for u16 {
200 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u16][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
201 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
202 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Charrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#Char# => {
203 if let 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#(c)) = char::decode_utf16rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]decode_utf16().([*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self]).nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/decode/impl#[`DecodeUtf16<I>`][Iterator]next().() {
204 c.formatrust-analyzer cargo sprintf 0.4.2 format/impl#[char][Printf]format().(spec)
205 } else {
206 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
207 }
208 }
209 _ => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec),
210 }
211 }
212 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[u16][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
213 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i32)
214 }
215 }
216
217 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for i8 {
218 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i8][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
219 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
220 // signed integer format
221 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecInt# => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[i64][Printf]format().(spec),
222 // unsigned-only formats
223 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::HexIntUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#HexIntUpper# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::OctIntrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#OctInt# => {
224 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u8).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u8][Printf]format().(spec)
225 }
226 // c_char
227 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Charrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#Char# => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u8).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u8][Printf]format().(spec),
228 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#),
229 }
230 }
231 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[i8][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
232 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i32)
233 }
234 }
235
236 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for u8 {
237 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u8][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
238 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
239 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Charrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#Char# => {
240 if self.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii().() {
241 char::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/convert/impl#[char][`From<u8>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[char][Printf]format().(spec)
242 } else {
243 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
244 }
245 }
246 _ => (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec),
247 }
248 }
249 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[u8][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
250 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as i32)
251 }
252 }
253
254 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for usize {
255 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[usize][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
256 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec)
257 }
258 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[usize][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
259 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i32][`TryFrom<usize>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
260 }
261 }
262
263 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for isize {
264 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[isize][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
265 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as u64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[u64][Printf]format().(spec)
266 }
267 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[isize][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
268 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i32][`TryFrom<isize>`]try_from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
269 }
270 }
271
272 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for f64 {
273 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[f64][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
274 let mut prefix = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
275 let mut number = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
276
277 // set up the sign
278 if self.is_sign_negativerust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_sign_negative().() {
279 prefix.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('-');
280 } else if spec.space_signrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#space_sign. {
281 prefix.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
282 } else if spec.force_signrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#force_sign. {
283 prefix.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('+');
284 }
285
286 if self.is_finiterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_finite().() {
287 let mut use_scientific = false;
288 let mut exp_symb = 'e';
289 let mut strip_trailing_0s = false;
290 let mut abs = self.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]abs().();
291 let mut exponent = abs.log10rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]log10().().floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]floor().() as i32;
292 let mut precision = match spec.precisionrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#precision. {
293 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(p) => p,
294 _ => {
295 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#);
296 }
297 };
298 if precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]le().0 {
299 precision = 0;
300 }
301 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
302 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecFloatLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecFloatUpper# => {
303 // default
304 }
305 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::SciFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#SciFloatLower# => {
306 use_scientific = true;
307 }
308 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::SciFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#SciFloatUpper# => {
309 use_scientific = true;
310 exp_symb = 'E';
311 }
312 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::CompactFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#CompactFloatLower# | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::CompactFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#CompactFloatUpper# => {
313 if spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().==rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq(). rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::CompactFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#CompactFloatUpper# {
314 exp_symb = 'E'
315 }
316 strip_trailing_0s = true;
317 if precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().0 {
318 precision = 1;
319 }
320 // exponent signifies significant digits - we must round now
321 // to (re)calculate the exponent
322 let rounding_factor = 10.0_f64.powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powf().((precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().exponent) as f64);
323 let rounded_fixed = (abs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().rounding_factor).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().();
324 abs = rounded_fixed rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().rounding_factor;
325 exponent = abs.log10rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]log10().().floorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]floor().() as i32;
326 if exponent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().4 || exponent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().precision {
327 use_scientific = true;
328 precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1;
329 } else {
330 // precision specifies the number of significant digits
331 precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().exponent;
332 }
333 }
334 _ => {
335 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#);
336 }
337 }
338
339 if use_scientific {
340 let mut normal = abs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().10.0_f64.powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powf().(exponent as f64);
341
342 if precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().0 {
343 let mut int_part = normal.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().();
344 let mut exp_factor = 10.0_f64.powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powf().(precision as f64);
345 let mut tail = ((normal rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().int_part) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().exp_factor).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u64;
346 while tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().exp_factor as u64 {
347 // Overflow, must round
348 int_part rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign().1.0;
349 tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().exp_factor as u64;
350 if int_part rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().10.0 {
351 // keep same precision - which means changing exponent
352 exponent rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1;
353 exp_factor rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign().10.0;
354 normal rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`DivAssign<Self>`]div_assign().10.0;
355 int_part = normal.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().();
356 tail = ((normal rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().int_part) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().exp_factor).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u64;
357 }
358 }
359
360 let mut rev_tail_str = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
361 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#precision {
362 rev_tail_str.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().((b'0' rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().(tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().10) as u8) as char);
363 tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign().10;
364 }
365 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", int_part));
366 number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('.');
367 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&rev_tail_str.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>());
368 if strip_trailing_0s {
369 number = number.trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().('0').to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
370 }
371 } else {
372 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", normal.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().()));
373 }
374 number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(exp_symb);
375 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:+03}", exponent));
376 } else {
377 if precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().0 {
378 let mut int_part = abs.truncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]trunc().();
379 let exp_factor = 10.0_f64.powfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]powf().(precision as f64);
380 let mut tail = ((abs rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().int_part) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().exp_factor).roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().() as u64;
381 let mut rev_tail_str = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
382 if tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]ge().exp_factor as u64 {
383 // overflow - we must round up
384 int_part rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`AddAssign<Self>`]add_assign().1.0;
385 tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().exp_factor as u64;
386 // no need to change the exponent as we don't have one
387 // (not scientific notation)
388 }
389 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#precision {
390 rev_tail_str.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().((b'0' rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().(tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().10) as u8) as char);
391 tail rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`DivAssign<Self>`]div_assign().10;
392 }
393 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", int_part));
394 number.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('.');
395 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&rev_tail_str.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>());
396 if strip_trailing_0s {
397 number = number.trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().('0').to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
398 }
399 } else {
400 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", abs.roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]round().()));
401 }
402 }
403 } else {
404 // not finite
405 match spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. {
406 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecFloatLower#
407 | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::SciFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#SciFloatLower#
408 | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::CompactFloatLowerrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#CompactFloatLower# => {
409 if self.is_infiniterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_infinite().() {
410 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("inf")
411 } else {
412 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("nan")
413 }
414 }
415 ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::DecFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#DecFloatUpper#
416 | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::SciFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#SciFloatUpper#
417 | ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::CompactFloatUpperrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#CompactFloatUpper# => {
418 if self.is_infiniterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_infinite().() {
419 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("INF")
420 } else {
421 number.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("NAN")
422 }
423 }
424 _ => {
425 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#);
426 }
427 }
428 }
429 // Take care of padding
430 let width: usize = match spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. {
431 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w) => w,
432 _ => {
433 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#); // should not happen at this point!!
434 }
435 }
436 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()
437 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_default().();
438 let formatted = if spec.left_adjrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#left_adj. {
439 let mut full_num = prefix 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().&number;
440 while full_num.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
441 full_num.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
442 }
443 full_num
444 } else if spec.zero_padrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#zero_pad. && self.is_finiterust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_finite().() {
445 while prefix.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().number.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
446 prefix.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('0');
447 }
448 prefix 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().&number
449 } else {
450 let mut full_num = prefix 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().&number;
451 while full_num.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
452 full_num = " ".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().&full_num;
453 }
454 full_num
455 };
456 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(formatted)
457 }
458 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[f64][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
459 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
460 }
461 }
462
463 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for f32 {
464 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[f32][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
465 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as f64).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[f64][Printf]format().(spec)
466 }
467 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[f32][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
468 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
469 }
470 }
471
472 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for &str {
473 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`&str`][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
474 if spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().==rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq(). rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Stringrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#String# {
475 let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
476
477 // Take care of precision, putting the truncated string in `content`
478 let precision: usize = match spec.precisionrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#precision. {
479 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(p) => p,
480 _ => {
481 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#); // should not happen at this point!!
482 }
483 }
484 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()
485 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_default().();
486 let content_len = {
487 let mut content_len = precision.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().());
488 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_char_boundaryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_char_boundary().(content_len) {
489 content_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
490 }
491 content_len
492 };
493 let content = &self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#content_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
494
495 // Pad to width if needed, putting the padded string in `s`
496 let width: usize = match spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. {
497 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w) => w,
498 _ => {
499 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#); // should not happen at this point!!
500 }
501 }
502 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()
503 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_default().();
504 if spec.left_adjrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#left_adj. {
505 s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(content);
506 while s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
507 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
508 }
509 } else {
510 while s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().content.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
511 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
512 }
513 s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(content);
514 }
515
516 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s)
517 } else {
518 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
519 }
520 }
521 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[`&str`][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
522 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
523 }
524 }
525
526 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for char {
527 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[char][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
528 if spec.conversion_typerust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#conversion_type. rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().==rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq(). rust-analyzer cargo sprintf 0.4.2 parser/impl#[ConversionType][`PartialEq<Self>`]eq().ConversionTyperust-analyzer cargo sprintf 0.4.2 parser/ConversionType#::Charrust-analyzer cargo sprintf 0.4.2 parser/ConversionType#Char# {
529 let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
530
531 let width: usize = match spec.widthrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#width. {
532 NumericParamrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#::Literalrust-analyzer cargo sprintf 0.4.2 parser/NumericParam#Literal#(w) => w,
533 _ => {
534 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::Unknownrust-analyzer cargo sprintf 0.4.2 PrintfError#Unknown#); // should not happen at this point!!
535 }
536 }
537 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()
538 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_default().();
539
540 if spec.left_adjrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#left_adj. {
541 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self);
542 while s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
543 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
544 }
545 } else {
546 while s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]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().self.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().width {
547 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
548 }
549 s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self);
550 }
551 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s)
552 } else {
553 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
554 }
555 }
556 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[char][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
557 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
558 }
559 }
560
561 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
562 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[String][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
563 (self as &str).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`&str`][Printf]format().(spec)
564 }
565 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[String][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
566 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
567 }
568 }
569
570 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for &CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr# {
571 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`&CStr`][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
572 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) = self.to_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_str().() {
573 s.formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`&str`][Printf]format().(spec)
574 } else {
575 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(PrintfErrorrust-analyzer cargo sprintf 0.4.2 PrintfError#::WrongTyperust-analyzer cargo sprintf 0.4.2 PrintfError#WrongType#)
576 }
577 }
578 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[`&CStr`][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
579 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
580 }
581 }
582
583 impl Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString# {
584 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[CString][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
585 self.as_c_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]as_c_str().().formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`&CStr`][Printf]format().(spec)
586 }
587 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[CString][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
588 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
589 }
590 }
591
592 impl<T> Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for *const T {
593 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`*const T`][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
594 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as usize).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[usize][Printf]format().(spec)
595 }
596 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[`*const T`][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
597 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
598 }
599 }
600
601 impl<T> Printfrust-analyzer cargo sprintf 0.4.2 format/Printf# for *mut T {
602 fn formatrust-analyzer cargo sprintf 0.4.2 format/impl#[`*mut T`][Printf]format().(&self, spec: &ConversionSpecifierrust-analyzer cargo sprintf 0.4.2 parser/ConversionSpecifier#) -> Resultrust-analyzer cargo sprintf 0.4.2 Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
603 (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self as usize).formatrust-analyzer cargo sprintf 0.4.2 format/impl#[usize][Printf]format().(spec)
604 }
605 fn as_intrust-analyzer cargo sprintf 0.4.2 format/impl#[`*mut T`][Printf]as_int().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> {
606 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
607 }
608 }