Skip to content

Commit

Permalink
refactor: simplify match statements and improve type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
aspizu committed Jan 14, 2025
1 parent 65cf7d9 commit 0b8434a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,7 @@ impl Repr {
}

pub fn overloads(name: &str) -> &'static [Self] {
match name {
_ => &[],
}
&[]
}

pub fn from_shape(name: &str, args: usize) -> Option<Self> {
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where T: Write + Seek
if args.len() != repr.args().len() {
d.report(
DiagnosticKind::ReprArgsCountMismatch {
repr: repr.clone(),
repr: *repr,
given: args.len(),
},
span,
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<'a> Mutation<'a> {
}
}

impl<'a> Display for Mutation<'a> {
impl Display for Mutation<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, r#","mutation":{{"tagName":"mutation","children":[]"#)?;
write!(f, r#","warp":"{}""#, self.warp)?;
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sb3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn qualify_struct_var_name(field_name: &str, var_name: &str) -> SmolStr {
format!("{}.{}", var_name, field_name).into()
}

impl<'a> S<'a> {
impl S<'_> {
pub fn is_name_list(&self, name: &Name) -> bool {
self.sprite.lists.contains_key(name.basename())
|| self
Expand Down
1 change: 0 additions & 1 deletion src/diagnostic/sprite_diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
fs::{
self,
File,
},
path::PathBuf,
};
Expand Down
5 changes: 2 additions & 3 deletions src/frontend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ pub fn build(input: Option<PathBuf>, output: Option<PathBuf>) -> Result<(), Buil
if sprite_path.file_stem().is_some_and(|stem| stem == "stage") {
continue;
}
if !sprite_path
.extension()
.is_some_and(|extension| extension == "gs")
if sprite_path
.extension().is_none_or(|extension| extension != "gs")
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lexer/adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'source> From<&'source str> for Lexer<'source> {
}
}

impl<'source> Iterator for Lexer<'source> {
impl Iterator for Lexer<'_> {
type Item = Result<(usize, Token, usize), Diagnostic>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion src/visitor/pass1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct S<'a> {
pub global_structs: Option<&'a FxHashMap<SmolStr, Struct>>,
}

impl<'a> S<'a> {
impl S<'_> {
pub fn get_var(&self, name: &str) -> Option<&Var> {
self.local_vars
.and_then(|local_vars| local_vars.get(name))
Expand Down

0 comments on commit 0b8434a

Please sign in to comment.