Skip to content

Commit 43ca000

Browse files
committed
chore: better struct declarations
1 parent 00427eb commit 43ca000

File tree

4 files changed

+9
-39
lines changed

4 files changed

+9
-39
lines changed

image/src/iterm.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,15 @@ use image::{imageops::FilterType, DynamicImage};
55
use std::env;
66
use std::io::Cursor;
77

8-
pub struct ITermBackend {}
8+
pub struct ITermBackend;
99

1010
impl ITermBackend {
11-
pub fn new() -> Self {
12-
ITermBackend {}
13-
}
14-
1511
pub fn supported() -> bool {
1612
let term_program = env::var("TERM_PROGRAM").unwrap_or_else(|_| "".to_string());
1713
term_program == "iTerm.app"
1814
}
1915
}
2016

21-
impl Default for ITermBackend {
22-
fn default() -> Self {
23-
Self::new()
24-
}
25-
}
26-
2717
impl super::ImageBackend for ITermBackend {
2818
fn add_image(
2919
&self,

image/src/kitty.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ use libc::{
99
use std::io::{stdout, Write};
1010
use std::time::Instant;
1111

12-
pub struct KittyBackend {}
12+
pub struct KittyBackend;
1313

1414
impl KittyBackend {
15-
pub fn new() -> Self {
16-
Self {}
17-
}
18-
1915
pub fn supported() -> bool {
2016
// save terminal attributes and disable canonical input processing mode
2117
let old_attributes = unsafe {
@@ -75,12 +71,6 @@ impl KittyBackend {
7571
}
7672
}
7773

78-
impl Default for KittyBackend {
79-
fn default() -> Self {
80-
Self::new()
81-
}
82-
}
83-
8474
impl super::ImageBackend for KittyBackend {
8575
fn add_image(
8676
&self,

image/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ pub trait ImageBackend {
2222
pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
2323
#[cfg(not(windows))]
2424
if sixel::SixelBackend::supported() {
25-
Some(Box::new(sixel::SixelBackend::new()))
25+
Some(Box::new(sixel::SixelBackend))
2626
} else if kitty::KittyBackend::supported() {
27-
Some(Box::new(kitty::KittyBackend::new()))
27+
Some(Box::new(kitty::KittyBackend))
2828
} else if iterm::ITermBackend::supported() {
29-
Some(Box::new(iterm::ITermBackend::new()))
29+
Some(Box::new(iterm::ITermBackend))
3030
} else {
3131
None
3232
}
@@ -39,9 +39,9 @@ pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
3939
pub fn get_image_backend(image_protocol: ImageProtocol) -> Option<Box<dyn ImageBackend>> {
4040
#[cfg(not(windows))]
4141
let backend = Some(match image_protocol {
42-
ImageProtocol::Kitty => Box::new(kitty::KittyBackend::new()) as Box<dyn ImageBackend>,
43-
ImageProtocol::Iterm => Box::new(iterm::ITermBackend::new()) as Box<dyn ImageBackend>,
44-
ImageProtocol::Sixel => Box::new(sixel::SixelBackend::new()) as Box<dyn ImageBackend>,
42+
ImageProtocol::Kitty => Box::new(kitty::KittyBackend) as Box<dyn ImageBackend>,
43+
ImageProtocol::Iterm => Box::new(iterm::ITermBackend) as Box<dyn ImageBackend>,
44+
ImageProtocol::Sixel => Box::new(sixel::SixelBackend) as Box<dyn ImageBackend>,
4545
});
4646

4747
#[cfg(windows)]

image/src/sixel.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ use libc::{
1212
use std::io::{stdout, Write};
1313
use std::time::Instant;
1414

15-
pub struct SixelBackend {}
15+
pub struct SixelBackend;
1616

1717
impl SixelBackend {
18-
pub fn new() -> Self {
19-
Self {}
20-
}
21-
2218
pub fn supported() -> bool {
2319
// save terminal attributes and disable canonical input processing mode
2420
let old_attributes = unsafe {
@@ -72,12 +68,6 @@ impl SixelBackend {
7268
}
7369
}
7470

75-
impl Default for SixelBackend {
76-
fn default() -> Self {
77-
Self::new()
78-
}
79-
}
80-
8171
impl super::ImageBackend for SixelBackend {
8272
#[allow(clippy::map_entry)]
8373
fn add_image(&self, lines: Vec<String>, image: &DynamicImage, colors: usize) -> Result<String> {

0 commit comments

Comments
 (0)