From 4be0a36d4e0c97dde55cf21360404471024b9e08 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Mon, 26 Jun 2017 08:38:56 +0100 Subject: [PATCH] Inline this thing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a function returns one of several enum variants, but we’re only interested in one, then just return its contents and have it apply the Mode “wrapper” later. --- src/options/view.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/options/view.rs b/src/options/view.rs index 7bc9298..349fda3 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -53,13 +53,11 @@ impl Mode { Err(Useless("oneline", true, "long")) } else { - let details = details::Options { + Ok(details::Options { columns: Some(Columns::deduce(matches)?), header: matches.opt_present("header"), xattr: xattr::ENABLED && matches.opt_present("extended"), - }; - - Ok(Mode::Details(details)) + }) } }; @@ -133,21 +131,15 @@ impl Mode { }; if matches.opt_present("long") { - let view = long()?; + let details = long()?; if matches.opt_present("grid") { - if let Mode::Details(details) = view { - let others = other_options_scan()?; - match others { - Mode::Grid(grid) => return Ok(Mode::GridDetails(grid, details)), - _ => return Ok(others), - }; - } - else { - unreachable!() - } + match other_options_scan()? { + Mode::Grid(grid) => return Ok(Mode::GridDetails(grid, details)), + others => return Ok(others), + }; } else { - return Ok(view); + return Ok(Mode::Details(details)); } }