summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyril Plisko <cyril.plisko@mountall.com>2020-11-08 13:44:39 +0200
committerCyril Plisko <cyril.plisko@mountall.com>2020-11-08 13:44:39 +0200
commit3b848699677e1dfeb1b16e8ee74bf633503d9764 (patch)
tree289ee64b1749facf3baf9bc30dd95360def71ade
parentc54054338cf1967ac7e71a816b60e386a96af58a (diff)
Rust 2018
-rw-r--r--Cargo.toml1
-rw-r--r--src/lib.rs29
-rw-r--r--src/utils.rs20
3 files changed, 25 insertions, 25 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8a9a59b..cfdf007 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ name = "pager"
readme = "README.md"
repository = "https://gitlab.com/imp/pager-rs.git"
version = "0.15.0" # remember to update html_root_url
+edition = "2018"
categories = ["command-line-interface", "text-processing"]
[badges]
diff --git a/src/lib.rs b/src/lib.rs
index 8c4c814..45e6e07 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -77,13 +77,16 @@
//! reflect the fact that no Pager is active.
#![doc(html_root_url = "https://docs.rs/pager/0.15.0")]
-#![cfg_attr(
- all(feature = "cargo-clippy", feature = "pedantic"),
- warn(clippy_pedantic)
-)]
-
-extern crate errno;
-extern crate libc;
+#![cfg_attr(feature = "pedantic", warn(clippy::pedantic))]
+#![warn(clippy::use_self)]
+#![warn(deprecated_in_future)]
+#![warn(future_incompatible)]
+#![warn(unreachable_pub)]
+#![warn(missing_debug_implementations)]
+#![warn(rust_2018_compatibility)]
+#![warn(rust_2018_idioms)]
+#![warn(unused)]
+#![deny(warnings)]
mod utils;
@@ -248,21 +251,21 @@ mod tests {
fn new<S: AsRef<OsStr>>(env: S) -> Self {
let env = env.as_ref().into();
if let Some(value) = env::var_os(&env) {
- PagerEnv::Reinstate(env, value)
+ Self::Reinstate(env, value)
} else {
- PagerEnv::Remove(env)
+ Self::Remove(env)
}
}
fn set<S: AsRef<OsStr>>(&self, value: S) {
match self {
- PagerEnv::Reinstate(env, _) | PagerEnv::Remove(env) => env::set_var(env, value),
+ Self::Reinstate(env, _) | Self::Remove(env) => env::set_var(env, value),
}
}
fn remove(&self) {
match self {
- PagerEnv::Reinstate(env, _) | PagerEnv::Remove(env) => env::remove_var(env),
+ Self::Reinstate(env, _) | Self::Remove(env) => env::remove_var(env),
}
}
}
@@ -270,8 +273,8 @@ mod tests {
impl Drop for PagerEnv {
fn drop(&mut self) {
match self {
- PagerEnv::Reinstate(env, value) => env::set_var(env, value),
- PagerEnv::Remove(env) => env::remove_var(env),
+ Self::Reinstate(env, value) => env::set_var(env, value),
+ Self::Remove(env) => env::remove_var(env),
}
}
}
diff --git a/src/utils.rs b/src/utils.rs
index 65bd8f8..493ab47 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -2,9 +2,6 @@ use std::ffi::{CString, OsString};
use std::os::unix::ffi::OsStringExt;
use std::ptr;
-use errno;
-use libc;
-
fn osstring2cstring(s: OsString) -> CString {
unsafe { CString::from_vec_unchecked(s.into_vec()) }
}
@@ -17,11 +14,11 @@ fn split_string(s: &OsString) -> Vec<OsString> {
}
// Helper wrappers around libc::* API
-pub fn fork() -> libc::pid_t {
+pub(crate) fn fork() -> libc::pid_t {
unsafe { libc::fork() }
}
-pub fn execvp(cmd: &OsString) {
+pub(crate) fn execvp(cmd: &OsString) {
let cstrings = split_string(cmd)
.into_iter()
.map(osstring2cstring)
@@ -32,7 +29,7 @@ pub fn execvp(cmd: &OsString) {
unsafe { libc::execvp(args[0], args.as_ptr()) };
}
-pub fn execvpe(cmd: &OsString, envs: &[OsString]) {
+pub(crate) fn execvpe(cmd: &OsString, envs: &[OsString]) {
let cstrings = split_string(cmd)
.into_iter()
.map(osstring2cstring)
@@ -56,21 +53,20 @@ pub fn execvpe(cmd: &OsString, envs: &[OsString]) {
unsafe { libc::execvpe(args[0], args.as_ptr(), envs.as_ptr()) };
}
-pub fn dup2(fd1: i32, fd2: i32) {
+pub(crate) fn dup2(fd1: i32, fd2: i32) {
assert!(unsafe { libc::dup2(fd1, fd2) } > -1);
}
-pub fn close(fd: i32) {
+pub(crate) fn close(fd: i32) {
assert_eq!(unsafe { libc::close(fd) }, 0);
}
-pub fn pipe() -> (i32, i32) {
+pub(crate) fn pipe() -> (i32, i32) {
let mut fds = [0; 2];
assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0);
(fds[0], fds[1])
}
-pub fn isatty(fd: i32) -> bool {
- let isatty = unsafe { libc::isatty(fd) };
- isatty != 0
+pub(crate) fn isatty(fd: i32) -> bool {
+ unsafe { libc::isatty(fd) != 0 }
}