Skip to content

Commit 7d4cf31

Browse files
de-vri-esnagisa
authored andcommitted
Replace Either dependency with Result.
1 parent 9d670ee commit 7d4cf31

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ exclude = [
1616
[dependencies]
1717
# Private dependencies.
1818
libc = "0.2"
19-
# Public dependencies, exposed through library API.
20-
either = "1.5"
2119

2220
[package.metadata.release]
2321
sign-commit = true

src/memfd.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,8 @@ impl Memfd {
172172
/// Otherwise the supplied `File` is returned for further usage.
173173
///
174174
/// [`File`]: fs::File
175-
pub fn try_from_file(file: fs::File) -> either::Either<Self, fs::File> {
176-
match Self::try_from_fd(file) {
177-
Ok(x) => either::Either::Left(x),
178-
Err(e) => either::Either::Right(e),
179-
}
175+
pub fn try_from_file(file: fs::File) -> Result<Self, fs::File> {
176+
Self::try_from_fd(file)
180177
}
181178

182179
/// Return a reference to the backing [`File`].

tests/memfd.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ fn test_memfd_from_into() {
4242
let m0 = opts.create("default").unwrap();
4343
let f0 = m0.into_file();
4444
let _ = memfd::Memfd::try_from_file(f0)
45-
.left()
4645
.expect("failed to convert a legit memfd file");
4746

4847
let rootdir = fs::File::open("/").unwrap();
4948
let _ = memfd::Memfd::try_from_file(rootdir)
50-
.right()
51-
.expect("unexpected conversion from a non-memfd file");
49+
.expect_err("unexpected conversion from a non-memfd file");
5250
}
5351

5452
/// Check if the close-on-exec flag is set for the memfd.

0 commit comments

Comments
 (0)