Skip to content

Commit bdbf9a5

Browse files
committed
Run Rustfmt
1 parent b54f765 commit bdbf9a5

File tree

21 files changed

+114
-90
lines changed

21 files changed

+114
-90
lines changed

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
match_block_trailing_comma = true

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/artifact/internal_artifact.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use regex::Regex;
2-
use std::hash::{Hash, Hasher};
31
use edit_distance;
42
use log::error;
3+
use regex::Regex;
4+
use std::hash::{Hash, Hasher};
55
use strum_macros::Display;
66

77
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
@@ -36,8 +36,7 @@ pub enum ArtifactSlot {
3636
Head,
3737
}
3838

39-
#[derive(Debug, Hash, Clone, PartialEq, Eq)]
40-
#[derive(Display)]
39+
#[derive(Debug, Hash, Clone, PartialEq, Eq, Display)]
4140
pub enum ArtifactSetName {
4241
ArchaicPetra,
4342
HeartOfDepth,
@@ -130,6 +129,7 @@ impl PartialEq for ArtifactStat {
130129
impl Eq for ArtifactStat {}
131130

132131
impl ArtifactStatName {
132+
#[rustfmt::skip]
133133
pub fn from_zh_cn(name: &str, is_percentage: bool) -> Option<ArtifactStatName> {
134134
match name {
135135
"治疗加成" => Some(ArtifactStatName::HealingBonus),
@@ -187,6 +187,7 @@ impl ArtifactStat {
187187
}
188188

189189
pub fn get_real_artifact_name_chs(raw: &str) -> Option<String> {
190+
#[rustfmt::skip]
190191
let all_artifact_chs = [
191192
"磐陀裂生之花", "嵯峨群峰之翼", "星罗圭壁之晷", "星罗圭璧之晷", "巉岩琢塑之樽", "不动玄石之相",
192193
"历经风雪的思念", "摧冰而行的执望", "冰雪故园的终期", "遍结寒霜的傲骨", "破冰踏雪的回音",
@@ -254,6 +255,7 @@ pub fn get_real_artifact_name_chs(raw: &str) -> Option<String> {
254255
}
255256

256257
impl ArtifactSetName {
258+
#[rustfmt::skip]
257259
pub fn from_zh_cn(s: &str) -> Option<ArtifactSetName> {
258260
// let s = match get_real_artifact_name_chs(s) {
259261
// Some(v) => v,
@@ -668,4 +670,3 @@ impl ArtifactSlot {
668670
}
669671
}
670672
}
671-

src/artifact/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub mod internal_artifact;
1+
pub mod internal_artifact;

src/capture/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#[cfg(target_os = "macos")]
2-
use std::{os::macos::raw};
2+
use std::os::macos::raw;
33

4-
use image::{Rgb, RgbImage, ImageBuffer, RgbaImage, buffer::ConvertBuffer, imageops::resize, imageops::FilterType::Triangle};
4+
use image::{
5+
buffer::ConvertBuffer, imageops::resize, imageops::FilterType::Triangle, ImageBuffer, Rgb,
6+
RgbImage, RgbaImage,
7+
};
58

69
use crate::common::color::Color;
710
use crate::common::PixelRect;
@@ -23,21 +26,24 @@ pub fn capture_absolute(
2326
.capture_area(*left, *top, *width as u32, *height as u32)
2427
.expect("capture failed");
2528
let mut rgb_img = png_decode(png_img).unwrap();
26-
if rgb_img.width() as i32> *width && rgb_img.height() as i32> *height {
29+
if rgb_img.width() as i32 > *width && rgb_img.height() as i32 > *height {
2730
rgb_img = resize(&rgb_img, (*width) as u32, (*height) as u32, Triangle);
2831
}
2932
Ok(rgb_img)
3033
}
3134

32-
fn png_decode(png_img:screenshots::Image) -> Result<RgbImage, String> {
35+
fn png_decode(png_img: screenshots::Image) -> Result<RgbImage, String> {
3336
let png_decoder = Decoder::new(png_img.buffer().as_slice());
3437
let mut png_reader = png_decoder.read_info().unwrap();
3538

3639
let mut png_data_buf = vec![0; png_reader.output_buffer_size()];
3740

3841
let info = png_reader.next_frame(&mut png_data_buf).unwrap();
39-
40-
assert!(info.color_type == png::ColorType::Rgba, "Not rgba format image");
42+
43+
assert!(
44+
info.color_type == png::ColorType::Rgba,
45+
"Not rgba format image"
46+
);
4147

4248
let mut buffer = png_data_buf[..info.buffer_size()].to_vec();
4349

@@ -63,7 +69,7 @@ pub fn capture_absolute_image(
6369

6470
let mut buffer = png_decode(image).unwrap();
6571

66-
if buffer.width() as i32> *width && buffer.height() as i32> *height {
72+
if buffer.width() as i32 > *width && buffer.height() as i32 > *height {
6773
buffer = resize(&buffer, (*width) as u32, (*height) as u32, Triangle);
6874
}
6975
Ok(buffer)

src/common/buffer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pub struct Buffer {
2-
pub data: Vec<Vec<f32>>
2+
pub data: Vec<Vec<f32>>,
33
}
44

55
impl Buffer {
66
fn new_zeroed(width: usize, height: usize) -> Buffer {
77
Buffer {
8-
data: vec![vec![0.0; width]; height]
8+
data: vec![vec![0.0; width]; height],
99
}
1010
}
11-
}
11+
}

src/common/character_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ lazy_static! {
7676

7777
set
7878
};
79-
}
79+
}

src/common/color.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[derive(Debug)]
2-
pub struct Color (pub u8, pub u8, pub u8);
2+
pub struct Color(pub u8, pub u8, pub u8);
33

44
impl Color {
55
pub fn is_same(&self, other: &Color) -> bool {
@@ -11,8 +11,7 @@ impl Color {
1111
pub fn dis_2(&self, other: &Color) -> u32 {
1212
let dis = (self.0 as i32 - other.0 as i32) * (self.0 as i32 - other.0 as i32)
1313
+ (self.1 as i32 - other.1 as i32) * (self.1 as i32 - other.1 as i32)
14-
+ (self.2 as i32 - other.2 as i32) * (self.2 as i32 - other.2 as i32)
15-
;
14+
+ (self.2 as i32 - other.2 as i32) * (self.2 as i32 - other.2 as i32);
1615
dis as u32
1716
}
1817

@@ -23,4 +22,4 @@ impl Color {
2322
pub fn from(r: u8, g: u8, b: u8) -> Color {
2423
Color(r, g, b)
2524
}
26-
}
25+
}

src/common/utils/mac.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub fn mac_scroll(enigo: &mut Enigo, count: i32) {
2121
}
2222
}
2323

24-
2524
pub fn get_titlebar_height() -> f64 {
2625
use cocoa::appkit::{NSBackingStoreBuffered, NSImage, NSWindow, NSWindowStyleMask};
2726
use cocoa::base::nil;

src/dto/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ use serde::Deserialize;
22

33
#[derive(Deserialize)]
44
pub struct GithubTag {
5-
pub name: String
5+
pub name: String,
66
}
7-

0 commit comments

Comments
 (0)