Skip to content

Commit

Permalink
Fix Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
siefkenj committed Apr 10, 2024
1 parent ad6ad8b commit e85ef5a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ jobs:
with:
command: fmt
args: --all -- --check

- name: Cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- --check
10 changes: 3 additions & 7 deletions tsify-next-macros/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ pub fn extract_doc_comments(attrs: &[syn::Attribute]) -> Vec<String> {
.filter_map(|a| {
// if the path segments include an ident of "doc" we know this
// this is a doc comment
if a.path()
.segments
.iter()
.any(|s| s.ident.to_string() == "doc")
{
if a.path().segments.iter().any(|s| s.ident == "doc") {
Some(a.to_token_stream().into_iter().filter_map(|t| match t {
TokenTree::Group(group) => {
// this will return the inner tokens of the group
Expand Down Expand Up @@ -62,10 +58,10 @@ pub fn write_doc_comments(
.collect::<Vec<_>>()
.join("");

write!(f, "{}", format!("/**\n{} */\n", comment))
write!(f, "{}", format_args!("/**\n{} */\n", comment))
}

pub fn clean_comments(typ: &mut TsType) -> () {
pub fn clean_comments(typ: &mut TsType) {
if let TsType::TypeLit(ref mut lit) = typ {
lit.members.iter_mut().for_each(|elem| {
elem.comments = vec![];
Expand Down
2 changes: 1 addition & 1 deletion tsify-next-macros/src/decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl TsTypeAliasDecl {
pub fn to_string_with_indent(&self, indent: usize) -> String {
let out = self.to_string();
let indent_str = " ".repeat(indent);
out.split("\n")
out.split('\n')
.map(|line| format!("{}{}", indent_str, line))
.collect::<Vec<_>>()
.join("\n")
Expand Down
1 change: 0 additions & 1 deletion tsify-next-macros/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ impl<'a> Parser<'a> {
self.container
.generics()
.type_params()
.into_iter()
.map(|p| p.ident.to_string())
.filter(|t| type_ref_names.contains(t))
.collect()
Expand Down
4 changes: 2 additions & 2 deletions tsify-next-macros/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl TsTypeLit {

self.members
.into_iter()
.chain(other.members.into_iter())
.chain(other.members)
.fold(init, |mut acc, m| {
if let Some(acc_m) = acc.get_mut(&m.key) {
let mut tmp = TsType::NULL;
Expand Down Expand Up @@ -655,7 +655,7 @@ impl TsTypeElement {
pub fn to_string_with_indent(&self, indent: usize) -> String {
let out = self.to_string();
let indent_str = " ".repeat(indent);
out.split("\n")
out.split('\n')
.map(|line| format!("{}{}", indent_str, line))
.collect::<Vec<_>>()
.join("\n")
Expand Down

0 comments on commit e85ef5a

Please sign in to comment.