Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Virgiel committed Dec 13, 2022
1 parent 2219e04 commit b544cfa
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion clients/core/src/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for ArrayIterator<'a, T> {
) -> Result<ArrayIterator<'a, T>, Box<dyn std::error::Error + Sync + Send>> {
let member_type = match *escape_domain(ty).kind() {
Kind::Array(ref member) => escape_domain(member),
_ => panic!("expected array type got {}", ty),
_ => panic!("expected array type got {ty}"),
};

let array = array_from_sql(raw)?;
Expand Down
2 changes: 1 addition & 1 deletion clients/core/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn escape_domain_to_sql<T: ToSql>(
) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let member_type = match *ty.kind() {
Kind::Array(ref member) => escape_domain(member),
_ => panic!("expected array type got {}", ty),
_ => panic!("expected array type got {ty}"),
};

let dimension = ArrayDimension {
Expand Down
2 changes: 1 addition & 1 deletion codegen_template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn gen_disp(s: &mut String, out: &str, ident: &str) {
}

/// Generate code to write interpolation patterns in `scan` into `out`
fn gen_recursive<'a>(scan: &'a mut Scanner, s: &mut String, out: &str) {
fn gen_recursive(scan: &mut Scanner, s: &mut String, out: &str) {
loop {
let (raw, pattern) = parse_next(scan);
if raw.is_empty() && pattern.is_none() {
Expand Down
8 changes: 4 additions & 4 deletions cornucopia/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl PreparedField {
pub fn own_struct(&self) -> String {
let it = self.ty.own_ty(self.is_inner_nullable);
if self.is_nullable {
format!("Option<{}>", it)
format!("Option<{it}>")
} else {
it
}
Expand All @@ -29,7 +29,7 @@ impl PreparedField {
.ty
.param_ergo_ty(self.is_inner_nullable, is_async, traits);
if self.is_nullable {
format!("Option<{}>", it)
format!("Option<{it}>")
} else {
it
}
Expand All @@ -38,7 +38,7 @@ impl PreparedField {
pub fn param_ty(&self, is_async: bool) -> String {
let it = self.ty.param_ty(self.is_inner_nullable, is_async);
if self.is_nullable {
format!("Option<{}>", it)
format!("Option<{it}>")
} else {
it
}
Expand All @@ -49,7 +49,7 @@ impl PreparedField {
.ty
.brw_ty(self.is_inner_nullable, has_lifetime, is_async);
if self.is_nullable {
format!("Option<{}>", it)
format!("Option<{it}>")
} else {
it
}
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/load_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn load_schema<P: AsRef<Path>>(client: &mut Client, paths: &[P]) -> Result<(
err,
})?;
client.batch_execute(&sql).map_err(|err| {
let msg = format!("{:#}", err);
let msg = format!("{err:#}");
let src = NamedSource::new(path.to_string_lossy(), sql);
if let Some((position, msg, help)) = db_err(&err) {
Error::Postgres {
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/prepare_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub(crate) mod error {
query_span: &SourceSpan,
query_name: &Span<String>,
) -> Self {
let msg = format!("{:#}", err);
let msg = format!("{err:#}");
if let Some((position, msg, help)) = db_err(err) {
Self::Db {
msg,
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/read_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl From<ModuleInfo> for NamedSource {

impl From<&ModuleInfo> for NamedSource {
fn from(m: &ModuleInfo) -> Self {
Self::new(&m.path.to_string_lossy(), m.content.clone())
Self::new(m.path.to_string_lossy(), m.content.clone())
}
}

Expand Down
9 changes: 3 additions & 6 deletions cornucopia/src/type_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ impl CornucopiaType {
CornucopiaType::Array { inner } => match inner.as_ref() {
CornucopiaType::Domain { inner, .. } => {
let ty = inner.accept_to_sql(is_async);
format!(
"cornucopia_{client_name}::private::DomainArray::<{}, &[{ty}]>",
ty
)
format!("cornucopia_{client_name}::private::DomainArray::<{ty}, &[{ty}]>")
}
_ => self.param_ty(false, is_async),
},
Expand Down Expand Up @@ -239,7 +236,7 @@ impl CornucopiaType {
..
} => {
if !is_copy && !is_params {
format!("{}Params<'a>", struct_path)
format!("{struct_path}Params<'a>")
} else {
self.brw_ty(is_inner_nullable, true, is_async)
}
Expand Down Expand Up @@ -288,7 +285,7 @@ impl CornucopiaType {
if *is_copy {
struct_path.to_string()
} else {
format!("{}Borrowed<{lifetime}>", struct_path)
format!("{struct_path}Borrowed<{lifetime}>")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn main() -> ExitCode {
/// Print error to stderr
fn display<T, E: Display>(result: Result<T, E>) -> Result<T, E> {
if let Err(err) = &result {
eprintln!("{}", err);
eprintln!("{err}");
}
result
}
Expand Down Expand Up @@ -285,7 +285,7 @@ fn run_codegen_test(
Run::Path(path) => {
// Switch directory
std::env::set_current_dir(&original_pwd)?;
std::env::set_current_dir(&format!("../{}", path))?;
std::env::set_current_dir(&format!("../{path}"))?;
true
}
};
Expand Down

0 comments on commit b544cfa

Please sign in to comment.