Skip to content

Commit 62ad5ce

Browse files
committed
refactoring
1 parent 2ec5fe7 commit 62ad5ce

File tree

4 files changed

+49
-58
lines changed

4 files changed

+49
-58
lines changed

src/diff/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ enum EnteredDelimiter<'s, 'v> {
138138
impl fmt::Debug for EnteredDelimiter<'_, '_> {
139139
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
140140
let desc = match self {
141-
EnteredDelimiter::PopEither((lhs_delims, rhs_delims)) => {
141+
Self::PopEither((lhs_delims, rhs_delims)) => {
142142
format!(
143143
"PopEither(lhs count: {}, rhs count: {})",
144144
lhs_delims.size(),
145145
rhs_delims.size()
146146
)
147147
}
148-
EnteredDelimiter::PopBoth(_) => "PopBoth".to_owned(),
148+
Self::PopBoth(_) => "PopBoth".to_owned(),
149149
};
150150
f.write_str(&desc)
151151
}

src/display/json.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ struct File<'f> {
3232
}
3333

3434
impl<'f> File<'f> {
35-
fn with_sections(
36-
language: &'f FileFormat,
37-
path: &'f str,
38-
chunks: Vec<Vec<Line<'f>>>,
39-
) -> Self {
35+
fn with_sections(language: &'f FileFormat, path: &'f str, chunks: Vec<Vec<Line<'f>>>) -> Self {
4036
File {
4137
language,
4238
path,

src/parse/guess_language.rs

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -525,54 +525,51 @@ fn from_emacs_mode_header(src: &str) -> Option<Language> {
525525
(Some(cap), _) | (_, Some(cap)) => cap[1].into(),
526526
_ => "".into(),
527527
};
528-
let lang = match mode_name.to_ascii_lowercase().trim() {
529-
"ada" => Some(Ada),
530-
"c" => Some(C),
531-
"clojure" => Some(Clojure),
532-
"csharp" => Some(CSharp),
533-
"css" => Some(Css),
534-
"dart" => Some(Dart),
535-
"c++" => Some(CPlusPlus),
536-
"elixir" => Some(Elixir),
537-
"elm" => Some(Elm),
538-
"elvish" => Some(Elvish),
539-
"emacs-lisp" => Some(EmacsLisp),
540-
"fsharp" => Some(FSharp),
541-
"gleam" => Some(Gleam),
542-
"go" => Some(Go),
543-
"haskell" => Some(Haskell),
544-
"hcl" => Some(Hcl),
545-
"html" => Some(Html),
546-
"janet" => Some(Janet),
547-
"java" => Some(Java),
548-
"js" | "js2" => Some(JavaScript),
549-
"lisp" => Some(CommonLisp),
550-
"nxml" => Some(Xml),
551-
"objc" => Some(ObjC),
552-
"perl" => Some(Perl),
553-
"python" => Some(Python),
554-
"racket" => Some(Racket),
555-
"rjsx" => Some(JavascriptJsx),
556-
"ruby" => Some(Ruby),
557-
"rust" => Some(Rust),
558-
"scala" => Some(Scala),
559-
"scss" => Some(Scss),
560-
"sh" => Some(Bash),
561-
"solidity" => Some(Solidity),
562-
"sql" => Some(Sql),
563-
"swift" => Some(Swift),
564-
"toml" => Some(Toml),
565-
"tuareg" => Some(OCaml),
566-
"typescript" => Some(TypeScript),
567-
"verilog" => Some(Verilog),
568-
"vhdl" => Some(Vhdl),
569-
"yaml" => Some(Yaml),
570-
"zig" => Some(Zig),
571-
_ => None,
572-
};
573-
if lang.is_some() {
574-
return lang;
575-
}
528+
return Some(match mode_name.to_ascii_lowercase().trim() {
529+
"ada" => Ada,
530+
"c" => C,
531+
"clojure" => Clojure,
532+
"csharp" => CSharp,
533+
"css" => Css,
534+
"dart" => Dart,
535+
"c++" => CPlusPlus,
536+
"elixir" => Elixir,
537+
"elm" => Elm,
538+
"elvish" => Elvish,
539+
"emacs-lisp" => EmacsLisp,
540+
"fsharp" => FSharp,
541+
"gleam" => Gleam,
542+
"go" => Go,
543+
"haskell" => Haskell,
544+
"hcl" => Hcl,
545+
"html" => Html,
546+
"janet" => Janet,
547+
"java" => Java,
548+
"js" | "js2" => JavaScript,
549+
"lisp" => CommonLisp,
550+
"nxml" => Xml,
551+
"objc" => ObjC,
552+
"perl" => Perl,
553+
"python" => Python,
554+
"racket" => Racket,
555+
"rjsx" => JavascriptJsx,
556+
"ruby" => Ruby,
557+
"rust" => Rust,
558+
"scala" => Scala,
559+
"scss" => Scss,
560+
"sh" => Bash,
561+
"solidity" => Solidity,
562+
"sql" => Sql,
563+
"swift" => Swift,
564+
"toml" => Toml,
565+
"tuareg" => OCaml,
566+
"typescript" => TypeScript,
567+
"verilog" => Verilog,
568+
"vhdl" => Vhdl,
569+
"yaml" => Yaml,
570+
"zig" => Zig,
571+
_ => continue,
572+
})
576573
}
577574

578575
None

src/parse/syntax.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,7 @@ impl MatchKind {
681681
pub(crate) fn is_novel(&self) -> bool {
682682
matches!(
683683
self,
684-
Self::Novel { .. }
685-
| Self::NovelWord { .. }
686-
| Self::UnchangedPartOfNovelItem { .. }
684+
Self::Novel { .. } | Self::NovelWord { .. } | Self::UnchangedPartOfNovelItem { .. }
687685
)
688686
}
689687
}

0 commit comments

Comments
 (0)