Skip to content

Commit d022a38

Browse files
committed
Use Box to reduce enum size
1 parent ab5e688 commit d022a38

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/config/man.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ impl ConfMan {
108108
}
109109
}
110110

111-
fig.extract().map_err(Exc::Conf)
111+
fig.extract().map_err(|e| Exc::Conf(Box::new(e)))
112112
}
113113
}

src/exc.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ pub enum Exc {
66
/// wraps all occurrences of errors in I/O operations
77
Io(std::io::Error),
88
/// wraps all occurrences of errors in SVG operations
9-
Svg(resvg::usvg::Error),
10-
Conf(figment::Error),
9+
Svg(Box<resvg::usvg::Error>),
10+
/// wraps all occurrences of errors in configuration loading
11+
Conf(Box<figment::Error>),
1112
/// wraps exceptions from the `xterm-query` crate
12-
Xterm(xterm_query::XQError),
13+
Xterm(Box<xterm_query::XQError>),
1314
/// wraps all other errors
1415
Other(String),
1516
}

src/gfx/kitty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ where
149149
/// * `timeout_ms` - the timeout in milliseconds
150150
fn query_raw(query: &str, timeout_ms: u64) -> Result<String, Exc> {
151151
enable_raw_mode().map_err(Exc::Io)?;
152-
let res = xterm_query::query_osc(query, timeout_ms).map_err(Exc::Xterm);
152+
let res = xterm_query::query_osc(query, timeout_ms).map_err(|e| Exc::Xterm(Box::new(e)));
153153
disable_raw_mode().map_err(Exc::Io)?;
154154

155155
res

src/gfx/svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn compute_rgba(path: &Path, size: u8) -> Result<Vec<u8>, Exc> {
5353

5454
// Create a default options struct with the target dimensions
5555
let opt = Options::default();
56-
let rtree = Tree::from_str(&svg_data, &opt).map_err(Exc::Svg)?;
56+
let rtree = Tree::from_str(&svg_data, &opt).map_err(|e| Exc::Svg(Box::new(e)))?;
5757

5858
// Create a pixmap with the desired dimensions
5959
let mut pixmap =

0 commit comments

Comments
 (0)