Skip to content

Commit

Permalink
clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
crusso committed Mar 18, 2024
1 parent 84c6438 commit f0f437a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rust/candid/src/pretty/candid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn pp_service(serv: &[(String, Type)]) -> RcDoc {

fn pp_defs(env: &TypeEnv) -> RcDoc {
lines(env.0.iter()
.filter(|(id, _)|{ !(*id == "blob") })
.filter(|(id, _)|{ *id != "blob" })
.map(|(id, ty)| {
kwd("type")
.append(ident(id))
Expand Down
2 changes: 1 addition & 1 deletion rust/candid_parser/src/bindings/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ fn pp_defs<'a>(
.map(|id| kwd("const").append(ident(id)).append(" = IDL.Rec();")),
);
let defs = lines(def_list.iter().
filter(|id|{ !(**id == "blob") }).
filter(|id|{ **id != "blob" }).
map(|id| {
let ty = env.find_type(id).unwrap();
if recs.contains(id) {
Expand Down
2 changes: 1 addition & 1 deletion rust/candid_parser/src/bindings/motoko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn pp_service(serv: &[(String, Type)]) -> RcDoc {

fn pp_defs(env: &TypeEnv) -> RcDoc {
lines(env.0.iter().
filter(|(id, _)|{ !(*id == "blob") }).
filter(|(id, _)|{ *id != "blob" }).
map(|(id, ty)| {
kwd("public type")
.append(escape(id, false))
Expand Down
15 changes: 7 additions & 8 deletions rust/candid_parser/src/bindings/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ fn pp_ty<'a>(ty: &'a Type, recs: &RecPoints) -> RcDoc<'a> {
Var(ref id) => {
if id == "blob" {
str("serde_bytes::ByteBuf")
}
else {
let name = ident(id, Some(Case::Pascal));
if recs.contains(id.as_str()) {
str("Box<").append(name).append(">")
} else {
name
}
let name = ident(id, Some(Case::Pascal));
if recs.contains(id.as_str()) {
str("Box<").append(name).append(">")
} else {
name
}
}
}
Principal => str("Principal"),
Expand Down Expand Up @@ -225,7 +224,7 @@ fn pp_defs<'a>(
&config.type_attributes
};
lines(def_list.iter().
filter(|id|{ !(**id == "blob") }).
filter(|id|{ **id != "blob" }).
map(|id| {
let ty = env.find_type(id).unwrap();
let name = ident(id, Some(Case::Pascal)).append(" ");
Expand Down
7 changes: 3 additions & 4 deletions rust/candid_parser/src/bindings/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ fn pp_ty<'a>(env: &'a TypeEnv, ty: &'a Type, is_ref: bool) -> RcDoc<'a> {
Var(ref id) => {
if id == "blob" {
str("Uint8Array | number[]")
} else
if is_ref {
} else if is_ref {
let ty = env.rec_find_type(id).unwrap();
if matches!(ty.as_ref(), Service(_) | Func(_)) {
pp_ty(env, ty, false)
} else {
ident(id)
ident(id)
}
} else {
ident(id)
Expand Down Expand Up @@ -146,7 +145,7 @@ fn pp_service<'a>(env: &'a TypeEnv, serv: &'a [(String, Type)]) -> RcDoc<'a> {

fn pp_defs<'a>(env: &'a TypeEnv, def_list: &'a [&'a str]) -> RcDoc<'a> {
lines(def_list.iter().
filter(|id|{ !(**id == "blob") }).
filter(|id|{ **id != "blob" }).
map(|id| {
let ty = env.find_type(id).unwrap();
let export = match ty.as_ref() {
Expand Down

0 comments on commit f0f437a

Please sign in to comment.