Commit 3c1c7541 authored by Cyril Plisko's avatar Cyril Plisko 🤔

Address some pedantic clippy warnings

parent 1c1c7903
......@@ -17,3 +17,6 @@ gitlab = { repository = "imp/pager-rs" }
[dependencies]
errno = "0.2"
libc = "0.2"
[features]
pedantic = []
......@@ -65,6 +65,8 @@
//! will skip initialization. The host application will continue as normal. `Pager::is_on()` will
//! reflect the fact that no Pager is active.
#![cfg_attr(all(feature = "cargo-clippy", feature = "pedantic"), warn(clippy_pedantic))]
extern crate errno;
extern crate libc;
......@@ -74,6 +76,7 @@ use std::ffi::OsString;
const DEFAULT_PAGER_ENV: &str = "PAGER";
/// Keeps track of the current pager state
#[derive(Debug, Default)]
pub struct Pager {
pager: Option<OsString>,
......@@ -85,14 +88,14 @@ pub struct Pager {
impl Pager {
/// Creates new instance of pager with default settings
pub fn new() -> Self {
Pager::with_env(DEFAULT_PAGER_ENV)
Self::with_env(DEFAULT_PAGER_ENV)
}
/// Creates new instance of pager using `env` environment variable instead of PAGER
pub fn with_env(env: &str) -> Self {
let pager = utils::find_pager(env);
Pager {
Self {
pager: pager,
env: String::from(env).into(),
on: true,
......@@ -102,12 +105,12 @@ impl Pager {
#[deprecated(since = "0.12.0", note = "use with_env() instead")]
pub fn env(env: &str) -> Self {
Pager::with_env(env)
Self::with_env(env)
}
/// Creates a new pager instance directly specifying the desired pager
pub fn with_pager(pager: &str) -> Self {
Pager {
Self {
pager: OsString::from(pager).into(),
env: None,
on: true,
......@@ -117,7 +120,7 @@ impl Pager {
/// Instructs `Pager` to bypass invoking pager if output is not a `tty`
pub fn skip_on_notty(self) -> Self {
Pager {
Self {
skip_on_notty: true,
..self
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment