Skip to content

Commit

Permalink
Replace Either dependency with Result.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es authored and nagisa committed Oct 19, 2020
1 parent 9d670ee commit 7d4cf31
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ exclude = [
[dependencies]
# Private dependencies.
libc = "0.2"
# Public dependencies, exposed through library API.
either = "1.5"

[package.metadata.release]
sign-commit = true
Expand Down
7 changes: 2 additions & 5 deletions src/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,8 @@ impl Memfd {
/// Otherwise the supplied `File` is returned for further usage.
///
/// [`File`]: fs::File
pub fn try_from_file(file: fs::File) -> either::Either<Self, fs::File> {
match Self::try_from_fd(file) {
Ok(x) => either::Either::Left(x),
Err(e) => either::Either::Right(e),
}
pub fn try_from_file(file: fs::File) -> Result<Self, fs::File> {
Self::try_from_fd(file)
}

/// Return a reference to the backing [`File`].
Expand Down
4 changes: 1 addition & 3 deletions tests/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ fn test_memfd_from_into() {
let m0 = opts.create("default").unwrap();
let f0 = m0.into_file();
let _ = memfd::Memfd::try_from_file(f0)
.left()
.expect("failed to convert a legit memfd file");

let rootdir = fs::File::open("/").unwrap();
let _ = memfd::Memfd::try_from_file(rootdir)
.right()
.expect("unexpected conversion from a non-memfd file");
.expect_err("unexpected conversion from a non-memfd file");
}

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

0 comments on commit 7d4cf31

Please sign in to comment.