Skip to content

Commit 15fe3f7

Browse files
committed
Rustfmt
1 parent 2ed1367 commit 15fe3f7

File tree

6 files changed

+29
-36
lines changed

6 files changed

+29
-36
lines changed

codegen/src/sqlstate.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ pub enum SqlState {{
9696

9797
write!(file,
9898
" /// An unknown code
99-
Other(String)
99+
Other(String),
100100
}}
101101
"
102102
).unwrap();
103103
}
104104

105105
fn make_map(codes: &[Code], file: &mut BufWriter<File>) {
106-
write!(file, "static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
106+
write!(file,
107+
"#[cfg_attr(rustfmt, rustfmt_skip)]
108+
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ").unwrap();
107109
let mut builder = phf_codegen::Map::new();
108110
for code in codes {
109111
builder.entry(&*code.code, &format!("SqlState::{}", code.variant));
@@ -119,7 +121,7 @@ impl SqlState {{
119121
pub fn from_code(s: String) -> SqlState {{
120122
match SQLSTATE_MAP.get(&*s) {{
121123
Some(state) => state.clone(),
122-
None => SqlState::Other(s)
124+
None => SqlState::Other(s),
123125
}}
124126
}}
125127

src/error/sqlstate.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ pub enum SqlState {
477477
/// `XX002`
478478
IndexCorrupted,
479479
/// An unknown code
480-
Other(String)
480+
Other(String),
481481
}
482+
#[cfg_attr(rustfmt, rustfmt_skip)]
482483
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
483484
key: 1897749892740154578,
484485
disps: &[
@@ -776,7 +777,7 @@ impl SqlState {
776777
pub fn from_code(s: String) -> SqlState {
777778
match SQLSTATE_MAP.get(&*s) {
778779
Some(state) => state.clone(),
779-
None => SqlState::Other(s)
780+
None => SqlState::Other(s),
780781
}
781782
}
782783

src/lib.rs

+12-27
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,7 @@ impl IntoConnectParams for Url {
180180
Err("unix socket support requires the `unix_socket` feature".into())
181181
}
182182

183-
let Url {
184-
host,
185-
port,
186-
user,
187-
path: url::Path { mut path, query: options, .. },
188-
..
189-
} = self;
183+
let Url { host, port, user, path: url::Path { mut path, query: options, .. }, .. } = self;
190184

191185
let maybe_path = try!(url::decode_component(&host));
192186
let target = if maybe_path.starts_with('/') {
@@ -711,7 +705,8 @@ impl InnerConnection {
711705
}
712706
CopyInResponse { .. } => {
713707
try!(self.write_messages(&[CopyFail {
714-
message: "COPY queries cannot be directly executed",
708+
message: "COPY queries cannot be directly \
709+
executed",
715710
},
716711
Sync]));
717712
}
@@ -746,7 +741,9 @@ impl InnerConnection {
746741
"expected {} parameters but got {}",
747742
param_types.len(),
748743
params.len());
749-
debug!("executing statement {} with parameters: {:?}", stmt_name, params);
744+
debug!("executing statement {} with parameters: {:?}",
745+
stmt_name,
746+
params);
750747
let mut values = vec![];
751748
for (param, ty) in params.iter().zip(param_types) {
752749
let mut buf = vec![];
@@ -857,28 +854,18 @@ impl InnerConnection {
857854

858855
let (name, type_, elem_oid, rngsubtype, basetype, schema, relid) = {
859856
let ctx = SessionInfo::new(self);
860-
let name = try!(String::from_sql(&Type::Name,
861-
&mut &**row[0].as_ref().unwrap(),
862-
&ctx));
863-
let type_ = try!(i8::from_sql(&Type::Char,
864-
&mut &**row[1].as_ref().unwrap(),
865-
&ctx));
866-
let elem_oid = try!(Oid::from_sql(&Type::Oid,
867-
&mut &**row[2].as_ref().unwrap(),
868-
&ctx));
857+
let name = try!(String::from_sql(&Type::Name, &mut &**row[0].as_ref().unwrap(), &ctx));
858+
let type_ = try!(i8::from_sql(&Type::Char, &mut &**row[1].as_ref().unwrap(), &ctx));
859+
let elem_oid = try!(Oid::from_sql(&Type::Oid, &mut &**row[2].as_ref().unwrap(), &ctx));
869860
let rngsubtype = match row[3] {
870861
Some(ref data) => try!(Option::<Oid>::from_sql(&Type::Oid, &mut &**data, &ctx)),
871862
None => try!(Option::<Oid>::from_sql_null(&Type::Oid, &ctx)),
872863
};
873-
let basetype = try!(Oid::from_sql(&Type::Oid,
874-
&mut &**row[4].as_ref().unwrap(),
875-
&ctx));
864+
let basetype = try!(Oid::from_sql(&Type::Oid, &mut &**row[4].as_ref().unwrap(), &ctx));
876865
let schema = try!(String::from_sql(&Type::Name,
877866
&mut &**row[5].as_ref().unwrap(),
878867
&ctx));
879-
let relid = try!(Oid::from_sql(&Type::Oid,
880-
&mut &**row[6].as_ref().unwrap(),
881-
&ctx));
868+
let relid = try!(Oid::from_sql(&Type::Oid, &mut &**row[6].as_ref().unwrap(), &ctx));
882869
(name, type_, elem_oid, rngsubtype, basetype, schema, relid)
883870
};
884871

@@ -930,9 +917,7 @@ impl InnerConnection {
930917
let name = try!(String::from_sql(&Type::Name,
931918
&mut &**row[0].as_ref().unwrap(),
932919
&ctx));
933-
let type_ = try!(Oid::from_sql(&Type::Oid,
934-
&mut &**row[1].as_ref().unwrap(),
935-
&ctx));
920+
let type_ = try!(Oid::from_sql(&Type::Oid, &mut &**row[1].as_ref().unwrap(), &ctx));
936921
(name, type_)
937922
};
938923
let type_ = try!(self.get_type(type_));

src/rows.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::fmt;
77
use std::ops::Deref;
88
use std::slice;
99

10-
use {Result, Transaction, DbErrorNew, SessionInfoNew, RowsNew, LazyRowsNew,
11-
StatementInternals, WrongTypeNew};
10+
use {Result, Transaction, DbErrorNew, SessionInfoNew, RowsNew, LazyRowsNew, StatementInternals,
11+
WrongTypeNew};
1212
use types::{FromSql, SessionInfo, WrongType};
1313
use stmt::{Statement, Column};
1414
use error::Error;

src/stmt.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ impl<'conn> Statement<'conn> {
8585
-> Result<(VecDeque<Vec<Option<Vec<u8>>>>, bool)> {
8686
let mut conn = self.conn.conn.borrow_mut();
8787

88-
try!(conn.raw_execute(&self.info.name, portal_name, row_limit, self.param_types(), params));
88+
try!(conn.raw_execute(&self.info.name,
89+
portal_name,
90+
row_limit,
91+
self.param_types(),
92+
params));
8993

9094
let mut buf = VecDeque::new();
9195
let more_rows = try!(conn.read_rows(&mut buf));

src/url.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ fn get_authority(rawurl: &str) -> DecodeResult<(Option<UserInfo>, &str, Option<u
376376
port = Some(&rawurl[pos + 1..end]);
377377
}
378378
State::Ip6Host |
379-
State::InHost | State::Start => host = &rawurl[begin..end],
379+
State::InHost |
380+
State::Start => host = &rawurl[begin..end],
380381
State::InPort => {
381382
if input != Input::Digit {
382383
return Err("Non-digit characters in port.".to_owned());

0 commit comments

Comments
 (0)