Skip to content

Commit

Permalink
refactor: simplify lifetimes and closures
Browse files Browse the repository at this point in the history
  • Loading branch information
gvozdvmozgu authored and benfdking committed Nov 19, 2024
1 parent c75ca49 commit 5b80357
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions crates/cli/src/commands_fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub(crate) fn run_fix(
if result
.paths
.iter()
.map(|path| path.files.iter().all(|file| file.violations.is_empty()))
.all(|v| v)
.all(|path| path.files.iter().all(|file| file.violations.is_empty()))
{
let count_files = result
.paths
Expand Down
1 change: 0 additions & 1 deletion crates/lib-core/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ impl<'a> Lexer<'a> {
}

/// Convert a tuple of lexed elements into a tuple of segments.

fn elements_to_segments(
&self,
elements: Vec<TemplateElement>,
Expand Down
6 changes: 3 additions & 3 deletions crates/lib-core/src/parser/segments/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ impl ErasedSegment {
.clone()
}

pub fn children<'set>(
&'set self,
seg_types: &'set SyntaxSet,
pub fn children(
&self,
seg_types: &'static SyntaxSet,
) -> impl Iterator<Item = &ErasedSegment> + '_ {
self.segments()
.iter()
Expand Down
6 changes: 3 additions & 3 deletions crates/lib-core/src/utils/analysis/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct Selectable<'me> {
pub dialect: &'me Dialect,
}

impl<'me> Selectable<'me> {
impl Selectable<'_> {
pub fn find_alias(&self, table: &str) -> Option<AliasInfo> {
self.select_info()
.as_ref()?
Expand All @@ -57,7 +57,7 @@ impl<'me> Selectable<'me> {
}
}

impl<'me> Selectable<'me> {
impl Selectable<'_> {
pub fn wildcard_info(&self) -> Vec<WildcardInfo> {
let Some(select_info) = self.select_info() else {
return Vec::new();
Expand Down Expand Up @@ -107,7 +107,7 @@ impl<'me> Selectable<'me> {
}
}

impl<'me> Selectable<'me> {
impl Selectable<'_> {
pub fn select_info(&self) -> Option<SelectStatementColumnsAndTables> {
if self.selectable.is_type(SyntaxKind::SelectStatement) {
return get_select_statement_info(&self.selectable, self.dialect.into(), false);
Expand Down
4 changes: 1 addition & 3 deletions crates/lib/src/core/linter/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ impl Linter {

expanded_paths
.par_iter()
.filter(|path| {
return !ignorer(Path::new(path));
})
.filter(|path| !ignorer(Path::new(path)))
.map(|path| {
let rendered = self.render_file(path.clone());
self.lint_rendered(rendered, fix)
Expand Down
1 change: 0 additions & 1 deletion crates/lib/src/core/string_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// String Helpers for the parser module.

/// Yields all the positions sbstr within in_str https://stackoverflow.com/questions/4664850/how-to-find-all-occurrences-of-a-substring
pub fn find_all(substr: &str, in_str: &str) -> Vec<usize> {
// Return nothing if one of the inputs is trivial
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/utils/functional/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct FunctionalContext<'a> {
}

impl<'a> FunctionalContext<'a> {
pub fn new(context: RuleContext<'a>) -> FunctionalContext {
pub fn new(context: RuleContext<'a>) -> Self {
FunctionalContext { context }
}

Expand Down

0 comments on commit 5b80357

Please sign in to comment.