Skip to content

Commit

Permalink
refactor: Remove unnecessary unwrap()
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanglover committed Apr 7, 2024
1 parent 385be17 commit 4905d86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn convert_largest_square_image_in_ico_to_png(
buf: Cursor<Vec<u8>>,
output_path: &str,
) -> Result<(), std::io::Error> {
let icondir = ico::IconDir::read(buf).unwrap();
let icondir = ico::IconDir::read(buf)?;
let mut largest_size = 0;
let mut largest_index = 0;

Expand All @@ -115,7 +115,7 @@ pub fn convert_largest_square_image_in_ico_to_png(
}
}

let image = icondir.entries()[largest_index].decode().unwrap();
let image = icondir.entries()[largest_index].decode()?;
let out_file = fs::File::create(output_path).unwrap();

image.write_png(out_file)
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ fn main() {
if is_container() {
start_server(ip, 39493)
} else if let Some(file) = file {
client::exec(address, &file, directory.to_str().unwrap());
if let Some(directory) = directory.to_str() {
client::exec(address, &file, directory);
} else {
notify("Invalid directory was given.", None)
}
} else {
notify("sakaya was called but no file was given.", None);
}
Expand Down

0 comments on commit 4905d86

Please sign in to comment.