Skip to content

Commit

Permalink
remove unneeded lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Mar 27, 2021
1 parent 1fcbbd9 commit aa205ce
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gtk/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum UiError {
}

impl UiError {
pub fn iter_sources(&self) -> ErrorIter<'_> { ErrorIter { current: self.source() } }
pub fn iter_sources(&self) -> ErrorIter { ErrorIter { current: self.source() } }
}

#[derive(Debug, Error)]
Expand Down
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Client {
pub fn new() -> Result<Self, client::Error> { client::Client::new().map(Client) }

/// Executes the recovery subcommand of the client.
pub fn recovery(&self, matches: &ArgMatches<'_>) -> Result<(), client::Error> {
pub fn recovery(&self, matches: &ArgMatches) -> Result<(), client::Error> {
match matches.subcommand() {
("upgrade", Some(matches)) => {
match matches.subcommand() {
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Client {
Ok(())
}

pub fn release(&self, matches: &ArgMatches<'_>) -> Result<(), client::Error> {
pub fn release(&self, matches: &ArgMatches) -> Result<(), client::Error> {
match matches.subcommand() {
("dismiss", _) => {
let devel = pop_upgrade::development_releases_enabled();
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Client {
Ok(())
}

pub fn status(&self, _matches: &ArgMatches<'_>) -> Result<(), client::Error> {
pub fn status(&self, _matches: &ArgMatches) -> Result<(), client::Error> {
let info = self.0.status()?;

let (status, sub_status) = match DaemonStatus::from_u8(info.status) {
Expand Down
2 changes: 1 addition & 1 deletion src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub struct Daemon {
}

impl Daemon {
pub fn new(_factory: &DbusFactory<'_>) -> Result<Self, DaemonError> {
pub fn new(_factory: &DbusFactory) -> Result<Self, DaemonError> {
let connection = Arc::new(
Connection::get_private(BusType::System).map_err(DaemonError::PrivateConnection)?,
);
Expand Down
1 change: 0 additions & 1 deletion src/daemon/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use dbus;
use std::io;
use thiserror::Error;

Expand Down
39 changes: 18 additions & 21 deletions src/daemon/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::result_signal;
// Methods supported by the daemon.
pub const CANCEL: &str = "Cancel";

pub fn cancel(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory<'_>) -> Method<MTFn<()>, ()> {
pub fn cancel(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(CANCEL, move |_| {
daemon.borrow_mut().cancel();
Ok(Vec::new())
Expand All @@ -39,7 +39,7 @@ pub enum DismissEvent {

pub fn dismiss_notification(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
dbus_factory
.method::<_, String>(DISMISS_NOTIFICATION, move |message| {
Expand All @@ -60,7 +60,7 @@ pub const FETCH_UPDATES: &str = "FetchUpdates";

pub fn fetch_updates(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method(FETCH_UPDATES, move |message| {
let mut daemon = daemon.borrow_mut();
Expand Down Expand Up @@ -94,7 +94,7 @@ pub const FETCH_UPDATES_STATUS: &str = "FetchUpdatesStatus";

pub fn fetch_updates_status(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, u8>(FETCH_UPDATES_STATUS, move |_| {
let (status, why) = result_signal(daemon.borrow().last_known.fetch.as_ref());
Expand All @@ -108,7 +108,7 @@ pub const PACKAGE_UPGRADE: &str = "UpgradePackages";

pub fn package_upgrade(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(PACKAGE_UPGRADE, move |_| {
daemon.borrow_mut().set_status(DaemonStatus::PackageUpgrade, move |daemon, active| {
Expand All @@ -127,7 +127,7 @@ pub const RECOVERY_UPGRADE_FILE: &str = "RecoveryUpgradeFile";

pub fn recovery_upgrade_file(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RECOVERY_UPGRADE_FILE, move |message| {
let mut daemon = daemon.borrow_mut();
Expand All @@ -148,7 +148,7 @@ pub const RECOVERY_UPGRADE_RELEASE: &str = "RecoveryUpgradeRelease";

pub fn recovery_upgrade_release(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RECOVERY_UPGRADE_RELEASE, move |message| {
let mut daemon = daemon.borrow_mut();
Expand Down Expand Up @@ -177,7 +177,7 @@ pub const RECOVERY_UPGRADE_RELEASE_STATUS: &str = "RecoveryUpgradeReleaseStatus"

pub fn recovery_upgrade_status(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, u8>(RECOVERY_UPGRADE_RELEASE_STATUS, move |_| {
let (status, why) = result_signal(daemon.borrow().last_known.recovery_upgrade.as_ref());
Expand All @@ -191,7 +191,7 @@ pub const RECOVERY_VERSION: &str = "RecoveryVersion";

pub fn recovery_version(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method(RECOVERY_VERSION, move |_message| {
daemon
Expand All @@ -205,10 +205,7 @@ pub fn recovery_version(

pub const REFRESH_OS: &str = "RefreshOS";

pub fn refresh_os(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
) -> Method<MTFn<()>, ()> {
pub fn refresh_os(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(REFRESH_OS, move |message| {
let enable = message.read1().map_err(|ref why| format_error(why))?;
let value = daemon.borrow_mut().refresh_os(match enable {
Expand All @@ -229,7 +226,7 @@ pub const RELEASE_CHECK: &str = "ReleaseCheck";

pub fn release_check(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method(RELEASE_CHECK, move |message| {
let development = message.read1().map_err(|ref why| format_error(why))?;
Expand All @@ -256,7 +253,7 @@ pub const RELEASE_UPGRADE: &str = "ReleaseUpgrade";

pub fn release_upgrade(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RELEASE_UPGRADE, move |message| {
let mut daemon = daemon.borrow_mut();
Expand All @@ -279,7 +276,7 @@ pub const RELEASE_UPGRADE_FINALIZE: &str = "ReleaseUpgradeFinalize";

pub fn release_upgrade_finalize(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RELEASE_UPGRADE_FINALIZE, move |_| {
daemon.borrow_mut().release_upgrade_finalize()?;
Expand All @@ -293,7 +290,7 @@ pub const RELEASE_UPGRADE_STATUS: &str = "ReleaseUpgradeStatus";

pub fn release_upgrade_status(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, u8>(RELEASE_UPGRADE_STATUS, move |_| {
let (status, why) = result_signal(daemon.borrow().last_known.release_upgrade.as_ref());
Expand All @@ -307,7 +304,7 @@ pub const RELEASE_REPAIR: &str = "ReleaseRepair";

pub fn release_repair(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RELEASE_REPAIR, move |_message| {
let mut daemon = daemon.borrow_mut();
Expand All @@ -321,7 +318,7 @@ pub fn release_repair(

pub const RESET: &str = "Reset";

pub fn reset(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory<'_>) -> Method<MTFn<()>, ()> {
pub fn reset(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(RESET, move |_| {
async_io::block_on(daemon.borrow_mut().reset())?;
Ok(Vec::new())
Expand All @@ -332,7 +329,7 @@ pub fn reset(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory<'_>) -> Met

pub const STATUS: &str = "Status";

pub fn status(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory<'_>) -> Method<MTFn<()>, ()> {
pub fn status(daemon: Rc<RefCell<Daemon>>, dbus_factory: &DbusFactory) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(STATUS, move |_| {
let daemon = daemon.borrow_mut();
let status = daemon.status.load(Ordering::SeqCst) as u8;
Expand All @@ -348,7 +345,7 @@ pub const UPDATE_CHECK: &str = "UpdateCheck";

pub fn update_check(
daemon: Rc<RefCell<Daemon>>,
dbus_factory: &DbusFactory<'_>,
dbus_factory: &DbusFactory,
) -> Method<MTFn<()>, ()> {
let method = dbus_factory.method::<_, String>(UPDATE_CHECK, move |_| {
let status = async_io::block_on(daemon.borrow_mut().update_and_restart());
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub enum SignalEvent {
}

impl Display for SignalEvent {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
use self::SignalEvent::*;
match self {
FetchResult(result) => write!(fmt, "fetch result: {:?}", result),
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl From<DaemonStatus> for &'static str {
}

impl Display for DaemonStatus {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(<&'static str>::from(*self))
}
}
4 changes: 2 additions & 2 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io;
use yansi::Paint;

pub fn setup_logging(filter: LevelFilter) -> Result<(), InitError> {
let location = |record: &Record<'_>| {
let location = |record: &Record| {
let mut target = record.target();
if let Some(pos) = target.find(':') {
target = &target[..pos];
Expand All @@ -22,7 +22,7 @@ pub fn setup_logging(filter: LevelFilter) -> Result<(), InitError> {
}
};

let format_level = |record: &Record<'_>| match record.level() {
let format_level = |record: &Record| match record.level() {
level @ Level::Trace => Paint::green(level).bold(),
level @ Level::Warn => Paint::yellow(level).bold(),
level @ Level::Error => Paint::red(level).bold(),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub fn main() {
}
}

fn main_(matches: &ArgMatches<'_>) -> Result<(), Error> {
fn main_(matches: &ArgMatches) -> Result<(), Error> {
init()?;

match matches.subcommand() {
Expand Down
2 changes: 1 addition & 1 deletion src/sighandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn status() -> Option<Signal> {
}

impl Display for Signal {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
let string = match *self {
Signal::Interrupt => "interrupt",
Signal::Hangup => "hangup",
Expand Down

0 comments on commit aa205ce

Please sign in to comment.