Skip to content

Commit f0e87dd

Browse files
committed
Add ignore-result dependency
In some cases none of the variants of the Result type matter, so it's best to just ignore them both. The ignore-result package provides the means to ignore botth Result variants.
1 parent 84386be commit f0e87dd

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ subprojects/bitflags-[0-9]*
66
subprojects/clap-[0-9]*
77
subprojects/clap_builder-[0-9]*
88
subprojects/clap_lex-[0-9]*
9+
subprojects/ignore-result-[0-9]*
910
subprojects/io-lifetimes-[0-9]*
1011
subprojects/itoa-[0-9]*
1112
subprojects/libc-[0-9]*

meson.build

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ if rustc.version().version_compare('<1.69')
1717
endif
1818

1919
clap_rs_dep = dependency('clap-rs', version: '>=4.1.13')
20+
ignore_result_rs_dep = dependency('ignore-result-rs', version: '>=0.2.0')
2021
serde_rs_dep = dependency('serde-rs', version: '>=1.0.160')
2122
serde_json_rs_dep = dependency('serde_json-rs', version: '>=1.0.96')
2223

2324
fqDataDir = get_option('prefix') / get_option('datadir') / 'refivar'
2425

25-
lib_refivar_rs_sources = [
26-
]
27-
2826
lib_refivar_guids_json = (
2927
meson.project_source_root() / 'src' / 'lib' / 'efivar' / 'guids.json'
3028
)
@@ -88,6 +86,7 @@ executable(
8886
link_with: lib_refivar,
8987
dependencies: [
9088
clap_rs_dep,
89+
ignore_result_rs_dep,
9190
serde_rs_dep,
9291
serde_json_rs_dep
9392
],

src/bin/efivar.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use clap;
22
use efivar::efi_guids;
3+
use ignore_result::Ignore;
4+
use std::io;
35
use std::process::ExitCode;
46

57
fn create_parser() -> clap::Command {
@@ -108,28 +110,24 @@ fn create_parser() -> clap::Command {
108110
}
109111

110112
fn main() -> ExitCode {
111-
let matches = create_parser().get_matches();
113+
let mut parser = create_parser();
114+
let matches = parser.get_matches_mut();
112115
if matches.get_flag("list-guids") {
113116
let mut guid_list: efi_guids::EfiGuidList = Default::default();
114117
match guid_list.load(matches.get_one("guids-list-path").unwrap()) {
115118
Ok(()) => {
116119
for g in guid_list.guids(efi_guids::GuidListSortField::Guid) {
117120
println!("{}", g);
118121
}
119-
println!("");
120-
for g in guid_list.guids(efi_guids::GuidListSortField::Id) {
121-
println!("{}", g);
122-
}
123-
println!("");
124-
for g in guid_list.guids(efi_guids::GuidListSortField::None) {
125-
println!("{}", g);
126-
}
127122
}
128123
Err(e) => {
129124
eprintln!("Failed to read GUIDs list file: {}", e);
130125
return std::process::ExitCode::from(1);
131126
}
132127
}
128+
} else {
129+
parser.write_help(&mut io::stderr()).ignore();
130+
return std::process::ExitCode::from(1);
133131
}
134132
return std::process::ExitCode::from(0);
135133
}

subprojects/ignore-result-rs.wrap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[wrap-file]
2+
directory = ignore-result-0.2.0
3+
4+
source_url = https://crates.io/api/v1/crates/ignore-result/0.2.0/download
5+
source_filename = ignore-result.tar.gz
6+
source_hash = 665ff4dce8edd10d490641ccb78949832f1ddbff02c584fb1f85ab888fe0e50c
7+
patch_directory = ignore-result-0.2.0
8+
9+
[provide]
10+
ignore-result-rs = ignore_result_rs_dep
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
project(
2+
'ignore-result-rs',
3+
'rust',
4+
version: '0.2.0',
5+
meson_version: '>=1.1.0',
6+
default_options: [
7+
'buildtype=debugoptimized',
8+
'rust_std=2021'
9+
]
10+
)
11+
12+
rustc = meson.get_compiler('rust')
13+
if rustc.version().version_compare('<1.69')
14+
error('rustc 1.69 required. Found ' + rustc.version())
15+
endif
16+
17+
lib_ignore_result = static_library('ignore_result', 'src/lib.rs',
18+
rust_args: [],
19+
rust_crate_type: 'rlib',
20+
dependencies: [],
21+
pic: true,
22+
)
23+
24+
ignore_result_rs_dep = declare_dependency(
25+
link_with: lib_ignore_result,
26+
dependencies: []
27+
)

0 commit comments

Comments
 (0)