Skip to content

Commit c03ba0b

Browse files
committed
update and cleanup.
1 parent 87cc9a8 commit c03ba0b

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "velvet-minecraft"
33
version = "1.0.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

src/get_minecraft_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[allow(unused_imports)]
2-
use anyhow::{anyhow, Result};
2+
use anyhow::{Result, anyhow};
33
use async_std::path::PathBuf;
44
use home::home_dir;
55

src/get_mods.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, Result};
1+
use anyhow::{Result, anyhow};
22
use async_std::fs::remove_file;
33
use async_std::{fs::File, path::PathBuf};
44
use async_std::{prelude::*, task};
@@ -107,7 +107,7 @@ pub async fn run(
107107
Ok(Status::Found(name, url, hash)) => {
108108
match existing_mods.get(name) {
109109
Some(x) if x == &hash => {
110-
println!("Already found \x1b[35m{}\x1b[39m.", name)
110+
println!("Already found \x1b[35m{name}\x1b[39m.")
111111
}
112112
_ => download_mods.push(task::spawn(download_mod(
113113
url,
@@ -123,7 +123,7 @@ pub async fn run(
123123

124124
for (name, hash) in existing_mods {
125125
if new_mods.get(name.as_str()) != Some(&hash) {
126-
println!("Removing \x1b[35m{}\x1b[39m.", name);
126+
println!("Removing \x1b[35m{name}\x1b[39m.");
127127
remove_file(path_mods.join(name).with_extension("jar")).await?
128128
}
129129
}
@@ -140,26 +140,25 @@ pub async fn run(
140140
}
141141

142142
async fn download_mod(url: String, file_name: &str, path: PathBuf, client: Client) -> Result<()> {
143-
println!("Downloading \x1b[35m{}\x1b[39m.", file_name);
143+
println!("Downloading \x1b[35m{file_name}\x1b[39m.");
144144
let path = path.join(file_name).with_extension("jar");
145145
let download = client.get(url).send().await?.bytes().await?;
146146
let mut mod_file = File::create(path).await?;
147147
mod_file.write(&download).await?;
148-
println!("Finished downloading \x1b[35m{}\x1b[39m.", file_name);
148+
println!("Finished downloading \x1b[35m{file_name}\x1b[39m.");
149149
Ok(())
150150
}
151151

152152
async fn check_latest(x: &'static str, client: Client, mc_version: String) -> Result<Status> {
153-
let mut modrinth_url = format!("{}/{}", MODRINTH_SERVER, x);
153+
let mut modrinth_url = format!("{MODRINTH_SERVER}/{x}");
154154
let name_response: Value = client.get(&modrinth_url).send().await?.json().await?;
155155
let name = name_response["slug"]
156156
.as_str()
157157
.ok_or_else(|| anyhow!("Couldn't get project name!"))?
158158
.to_owned();
159159

160160
modrinth_url = format!(
161-
"{}/version?loaders=[\"fabric\", \"quilt\"]&game_versions=[{:?}]",
162-
modrinth_url, mc_version
161+
"{modrinth_url}/version?loaders=[\"fabric\", \"quilt\"]&game_versions=[{mc_version:?}]"
163162
);
164163

165164
let version_response: Value = client.get(&modrinth_url).send().await?.json().await?;

src/install_velvet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{get_minecraft_dir, write_json};
2-
use anyhow::{anyhow, Result};
2+
use anyhow::{Result, anyhow};
33
use async_std::fs::File;
44
use async_std::fs::{self, create_dir_all};
55
use async_std::path::PathBuf;
@@ -23,7 +23,7 @@ pub async fn run(mc_version: &String, quilt_version: &String) -> Result<(PathBuf
2323

2424
let mut path_versions: PathBuf = PathBuf::from(&velvet_path).join("versions");
2525
let parent_dir = path_versions.clone();
26-
path_versions.push(format!("{}.json", mc_version));
26+
path_versions.push(format!("{mc_version}.json"));
2727
if !path_versions.exists().await {
2828
create_dir_all(parent_dir).await?;
2929
File::create(&path_versions).await?;
@@ -37,7 +37,7 @@ pub async fn run(mc_version: &String, quilt_version: &String) -> Result<(PathBuf
3737
.join("versions")
3838
.join(&version_folder_name);
3939
fs::create_dir_all(&path_version).await?;
40-
path_version.push(format!("{}.jar", version_folder_name));
40+
path_version.push(format!("{version_folder_name}.jar"));
4141
fs::File::create(&path_version).await?; // dummy jar required by the launcher.
4242

4343
path_version.set_extension("json");

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ mod get_mods;
1010
mod install_velvet;
1111
pub mod write_json;
1212

13-
use iced::widget::{button, checkbox, column, pick_list, text, Column, Space};
13+
use iced::widget::{Column, Space, button, checkbox, column, pick_list, text};
1414
use iced::{
15-
application, theme::Palette, window, Alignment, Color, Element, Length, Size, Task, Theme,
15+
Alignment, Color, Element, Length, Size, Task, Theme, application, theme::Palette, window,
1616
};
1717

1818
#[derive(Deserialize)]
@@ -180,7 +180,8 @@ impl Velvet {
180180
self.version_list.clone(),
181181
self.version.clone(),
182182
Message::Update
183-
).placeholder("Loading...")
183+
)
184+
.placeholder("Loading...")
184185
.width(Length::Fixed(200.0)),
185186
Space::with_height(Length::Fixed(5.0)),
186187
checkbox("Show snapshots", self.snapshot).on_toggle(Message::Snapshot),

0 commit comments

Comments
 (0)