Skip to content

Commit 6a86f8d

Browse files
committed
Rustfmt
1 parent 3809972 commit 6a86f8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2639
-1606
lines changed

codegen/src/sqlstate.rs

+37-22
Original file line numberDiff line numberDiff line change
@@ -71,43 +71,51 @@ fn variant_name(code: &str) -> Option<String> {
7171
}
7272

7373
fn make_header(file: &mut BufWriter<File>) {
74-
write!(file,
75-
"// Autogenerated file - DO NOT EDIT
74+
write!(
75+
file,
76+
"// Autogenerated file - DO NOT EDIT
7677
use phf;
7778
7879
"
79-
).unwrap();
80+
).unwrap();
8081
}
8182

8283
fn make_enum(codes: &[Code], file: &mut BufWriter<File>) {
83-
write!(file,
84-
r#"/// SQLSTATE error codes
84+
write!(
85+
file,
86+
r#"/// SQLSTATE error codes
8587
#[derive(PartialEq, Eq, Clone, Debug)]
8688
#[allow(enum_variant_names)]
8789
pub enum SqlState {{
8890
"#
89-
).unwrap();
91+
).unwrap();
9092

9193
for code in codes {
92-
write!(file,
93-
" /// `{}`
94+
write!(
95+
file,
96+
" /// `{}`
9497
{},\n",
95-
code.code, code.variant).unwrap();
98+
code.code,
99+
code.variant
100+
).unwrap();
96101
}
97102

98-
write!(file,
99-
" /// An unknown code
103+
write!(
104+
file,
105+
" /// An unknown code
100106
Other(String),
101107
}}
102108
103109
"
104-
).unwrap();
110+
).unwrap();
105111
}
106112

107113
fn make_map(codes: &[Code], file: &mut BufWriter<File>) {
108-
write!(file,
109-
"#[cfg_attr(rustfmt, rustfmt_skip)]
110-
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
114+
write!(
115+
file,
116+
"#[cfg_attr(rustfmt, rustfmt_skip)]
117+
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
118+
).unwrap();
111119
let mut builder = phf_codegen::Map::new();
112120
for code in codes {
113121
builder.entry(&*code.code, &format!("SqlState::{}", code.variant));
@@ -117,7 +125,9 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
117125
}
118126

119127
fn make_impl(codes: &[Code], file: &mut BufWriter<File>) {
120-
write!(file, r#"
128+
write!(
129+
file,
130+
r#"
121131
impl SqlState {{
122132
/// Creates a `SqlState` from its error code.
123133
pub fn from_code(s: &str) -> SqlState {{
@@ -130,20 +140,25 @@ impl SqlState {{
130140
/// Returns the error code corresponding to the `SqlState`.
131141
pub fn code(&self) -> &str {{
132142
match *self {{"#
133-
).unwrap();
143+
).unwrap();
134144

135145
for code in codes {
136-
write!(file, r#"
146+
write!(
147+
file,
148+
r#"
137149
SqlState::{} => "{}","#,
138-
code.variant, code.code).unwrap();
150+
code.variant,
151+
code.code
152+
).unwrap();
139153
}
140154

141-
write!(file, r#"
155+
write!(
156+
file,
157+
r#"
142158
SqlState::Other(ref s) => s,
143159
}}
144160
}}
145161
}}
146162
"#
147-
).unwrap();
163+
).unwrap();
148164
}
149-

codegen/src/type_gen.rs

+52-31
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
9494
let doc = array_re.replace(name, "$1[]");
9595
let mut doc = doc.to_ascii_uppercase();
9696

97-
let descr = lines.peek()
98-
.and_then(|line| doc_re.captures(line))
99-
.and_then(|captures| captures.at(1));
97+
let descr = lines
98+
.peek()
99+
.and_then(|line| doc_re.captures(line))
100+
.and_then(|captures| captures.at(1));
100101
if let Some(descr) = descr {
101102
doc.push_str(" - ");
102103
doc.push_str(descr);
@@ -119,38 +120,45 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
119120
}
120121

121122
fn make_header(w: &mut BufWriter<File>) {
122-
write!(w,
123-
"// Autogenerated file - DO NOT EDIT
123+
write!(
124+
w,
125+
"// Autogenerated file - DO NOT EDIT
124126
use std::fmt;
125127
126128
use types::{{Oid, Kind, Other}};
127129
128130
"
129-
).unwrap();
131+
).unwrap();
130132
}
131133

132134
fn make_enum(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
133-
write!(w,
134-
"/// A Postgres type.
135+
write!(
136+
w,
137+
"/// A Postgres type.
135138
#[derive(PartialEq, Eq, Clone, Debug)]
136139
pub enum Type {{
137140
"
138-
).unwrap();
141+
).unwrap();
139142

140143
for type_ in types.values() {
141-
write!(w,
142-
" /// {}
144+
write!(
145+
w,
146+
" /// {}
143147
{},
144-
"
145-
, type_.doc, type_.variant).unwrap();
148+
",
149+
type_.doc,
150+
type_.variant
151+
).unwrap();
146152
}
147153

148-
write!(w,
149-
r" /// An unknown type.
154+
write!(
155+
w,
156+
r" /// An unknown type.
150157
Other(Other),
151158
}}
152159
153-
" ).unwrap();
160+
"
161+
).unwrap();
154162
}
155163

156164
fn make_display_impl(w: &mut BufWriter<File>) {
@@ -180,10 +188,13 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
180188
).unwrap();
181189

182190
for (oid, type_) in types {
183-
write!(w,
184-
" {} => Some(Type::{}),
191+
write!(
192+
w,
193+
" {} => Some(Type::{}),
185194
",
186-
oid, type_.variant).unwrap();
195+
oid,
196+
type_.variant
197+
).unwrap();
187198
}
188199

189200
write!(w,
@@ -199,10 +210,13 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
199210

200211

201212
for (oid, type_) in types {
202-
write!(w,
203-
" Type::{} => {},
213+
write!(
214+
w,
215+
" Type::{} => {},
204216
",
205-
type_.variant, oid).unwrap();
217+
type_.variant,
218+
oid
219+
).unwrap();
206220
}
207221

208222
write!(w,
@@ -224,13 +238,16 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
224238
_ => "Simple".to_owned(),
225239
};
226240

227-
write!(w,
228-
" Type::{} => {{
241+
write!(
242+
w,
243+
" Type::{} => {{
229244
const V: &'static Kind = &Kind::{};
230245
V
231246
}}
232247
",
233-
type_.variant, kind).unwrap();
248+
type_.variant,
249+
kind
250+
).unwrap();
234251
}
235252

236253
write!(w,
@@ -253,17 +270,21 @@ r#" Type::Other(ref u) => u.kind(),
253270
).unwrap();
254271

255272
for type_ in types.values() {
256-
write!(w,
257-
r#" Type::{} => "{}",
273+
write!(
274+
w,
275+
r#" Type::{} => "{}",
258276
"#,
259-
type_.variant, type_.name).unwrap();
277+
type_.variant,
278+
type_.name
279+
).unwrap();
260280
}
261281

262-
write!(w,
263-
" Type::Other(ref u) => u.name(),
282+
write!(
283+
w,
284+
" Type::Other(ref u) => u.name(),
264285
}}
265286
}}
266287
}}
267288
"
268-
).unwrap();
289+
).unwrap();
269290
}

postgres-protocol/src/authentication/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ mod test {
3030
let password = b"password";
3131
let salt = [0x2a, 0x3d, 0x8f, 0xe0];
3232

33-
assert_eq!(md5_hash(username, password, salt),
34-
"md562af4dd09bbb41884907a838a3233294");
33+
assert_eq!(
34+
md5_hash(username, password, salt),
35+
"md562af4dd09bbb41884907a838a3233294"
36+
);
3537
}
3638
}

0 commit comments

Comments
 (0)