summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteveLauC <stevelauc@outlook.com>2022-08-09 12:15:52 +0800
committerSteveLauC <stevelauc@outlook.com>2022-08-09 12:15:52 +0800
commitd458ecd4e1205d36230ecac85c67472e3227a92d (patch)
treedc1c842152d1f6709ca4366ed92c40fb7d8aad2b /src
parenta10078f35c9564950035dfc88cb3a2cd9f3d9be3 (diff)
downloadnix-d458ecd4e1205d36230ecac85c67472e3227a92d.zip
remove deprecated items
Diffstat (limited to 'src')
-rw-r--r--src/sched.rs4
-rw-r--r--src/sys/personality.rs2
-rw-r--r--src/sys/quota.rs4
-rw-r--r--src/sys/socket/mod.rs2
-rw-r--r--src/sys/socket/sockopt.rs2
-rw-r--r--src/sys/termios.rs10
-rw-r--r--src/sys/time.rs62
-rw-r--r--src/unistd.rs66
8 files changed, 76 insertions, 76 deletions
diff --git a/src/sched.rs b/src/sched.rs
index e736f8d2..e9a326e2 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -233,8 +233,8 @@ mod sched_affinity {
/// use nix::unistd::Pid;
///
/// let mut cpu_set = CpuSet::new();
- /// cpu_set.set(0);
- /// sched_setaffinity(Pid::from_raw(0), &cpu_set);
+ /// cpu_set.set(0).unwrap();
+ /// sched_setaffinity(Pid::from_raw(0), &cpu_set).unwrap();
/// ```
pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()> {
let res = unsafe {
diff --git a/src/sys/personality.rs b/src/sys/personality.rs
index 2af66878..15b59017 100644
--- a/src/sys/personality.rs
+++ b/src/sys/personality.rs
@@ -86,7 +86,7 @@ pub fn get() -> Result<Persona> {
/// # use nix::sys::personality::{self, Persona};
/// let mut pers = personality::get().unwrap();
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));
-/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE);
+/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE).unwrap().unwrap();
/// ```
pub fn set(persona: Persona) -> Result<Persona> {
let res = unsafe {
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index 6e34e38d..f3b4c02d 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -6,11 +6,11 @@
//!
//! ```rust,no_run
//! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags};
-//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user");
+//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user").unwrap();
//! let mut dqblk: Dqblk = Default::default();
//! dqblk.set_blocks_hard_limit(10000);
//! dqblk.set_blocks_soft_limit(8000);
-//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS);
+//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS).unwrap();
//! ```
use std::default::Default;
use std::{mem, ptr};
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 2dfa8ec6..7e6d6094 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -677,7 +677,7 @@ pub enum ControlMessageOwned {
/// None).unwrap();
/// setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap();
/// let localhost = SockaddrIn::from_str("127.0.0.1:0").unwrap();
- /// bind(in_socket, &localhost);
+ /// bind(in_socket, &localhost).unwrap();
/// let address: SockaddrIn = getsockname(in_socket).unwrap();
/// // Get initial time
/// let time0 = SystemTime::now();
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index fff496db..1cbb223e 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -982,7 +982,7 @@ mod test {
let a_cred = getsockopt(a, super::PeerCredentials).unwrap();
let b_cred = getsockopt(b, super::PeerCredentials).unwrap();
assert_eq!(a_cred, b_cred);
- assert!(a_cred.pid() != 0);
+ assert_ne!(a_cred.pid(), 0);
}
#[test]
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index feb52c0a..c5b27d28 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -64,9 +64,9 @@
//! # use nix::sys::termios::{BaudRate, cfsetispeed, cfsetospeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
-//! cfsetispeed(&mut t, BaudRate::B9600);
-//! cfsetospeed(&mut t, BaudRate::B9600);
-//! cfsetspeed(&mut t, BaudRate::B9600);
+//! cfsetispeed(&mut t, BaudRate::B9600).unwrap();
+//! cfsetospeed(&mut t, BaudRate::B9600).unwrap();
+//! cfsetspeed(&mut t, BaudRate::B9600).unwrap();
//! # }
//! ```
//!
@@ -76,10 +76,10 @@
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetispeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
-//! # cfsetspeed(&mut t, BaudRate::B9600);
+//! # cfsetspeed(&mut t, BaudRate::B9600).unwrap();
//! let speed = cfgetispeed(&t);
//! assert_eq!(speed, cfgetospeed(&t));
-//! cfsetispeed(&mut t, speed);
+//! cfsetispeed(&mut t, speed).unwrap();
//! # }
//! ```
//!
diff --git a/src/sys/time.rs b/src/sys/time.rs
index b7ab3986..36279978 100644
--- a/src/sys/time.rs
+++ b/src/sys/time.rs
@@ -7,17 +7,17 @@ use std::time::Duration;
use std::{cmp, fmt, ops};
#[cfg(any(
- all(feature = "time", any(target_os = "android", target_os = "linux")),
- all(
- any(
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "linux",
- target_os = "netbsd"
- ),
- feature = "time",
- feature = "signal"
- )
+all(feature = "time", any(target_os = "android", target_os = "linux")),
+all(
+any(
+target_os = "freebsd",
+target_os = "illumos",
+target_os = "linux",
+target_os = "netbsd"
+),
+feature = "time",
+feature = "signal"
+)
))]
pub(crate) mod timer {
use crate::sys::time::TimeSpec;
@@ -98,10 +98,10 @@ pub(crate) mod timer {
}
}
#[cfg(any(
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "dragonfly",
- target_os = "illumos"
+ target_os = "freebsd",
+ target_os = "netbsd",
+ target_os = "dragonfly",
+ target_os = "illumos"
))]
bitflags! {
/// Flags that are used for arming the timer.
@@ -114,17 +114,17 @@ pub(crate) mod timer {
fn from(timerspec: TimerSpec) -> Expiration {
match timerspec {
TimerSpec(libc::itimerspec {
- it_interval:
- libc::timespec {
- tv_sec: 0,
- tv_nsec: 0,
- },
- it_value: ts,
- }) => Expiration::OneShot(ts.into()),
+ it_interval:
+ libc::timespec {
+ tv_sec: 0,
+ tv_nsec: 0,
+ },
+ it_value: ts,
+ }) => Expiration::OneShot(ts.into()),
TimerSpec(libc::itimerspec {
- it_interval: int_ts,
- it_value: val_ts,
- }) => {
+ it_interval: int_ts,
+ it_value: val_ts,
+ }) => {
if (int_ts.tv_sec == val_ts.tv_sec)
&& (int_ts.tv_nsec == val_ts.tv_nsec)
{
@@ -193,7 +193,7 @@ const SECS_PER_MINUTE: i64 = 60;
const SECS_PER_HOUR: i64 = 3600;
#[cfg(target_pointer_width = "64")]
-const TS_MAX_SECONDS: i64 = (::std::i64::MAX / NANOS_PER_SEC) - 1;
+const TS_MAX_SECONDS: i64 = (i64::MAX / NANOS_PER_SEC) - 1;
#[cfg(target_pointer_width = "32")]
const TS_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
@@ -453,7 +453,7 @@ pub struct TimeVal(timeval);
const MICROS_PER_SEC: i64 = 1_000_000;
#[cfg(target_pointer_width = "64")]
-const TV_MAX_SECONDS: i64 = (::std::i64::MAX / MICROS_PER_SEC) - 1;
+const TV_MAX_SECONDS: i64 = (i64::MAX / MICROS_PER_SEC) - 1;
#[cfg(target_pointer_width = "32")]
const TV_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
@@ -713,7 +713,7 @@ mod test {
#[test]
pub fn test_timespec() {
- assert!(TimeSpec::seconds(1) != TimeSpec::zero());
+ assert_ne!(TimeSpec::seconds(1), TimeSpec::zero());
assert_eq!(
TimeSpec::seconds(1) + TimeSpec::seconds(2),
TimeSpec::seconds(3)
@@ -743,7 +743,7 @@ mod test {
#[test]
pub fn test_timespec_ord() {
- assert!(TimeSpec::seconds(1) == TimeSpec::nanoseconds(1_000_000_000));
+ assert_eq!(TimeSpec::seconds(1), TimeSpec::nanoseconds(1_000_000_000));
assert!(TimeSpec::seconds(1) < TimeSpec::nanoseconds(1_000_000_001));
assert!(TimeSpec::seconds(1) > TimeSpec::nanoseconds(999_999_999));
assert!(TimeSpec::seconds(-1) < TimeSpec::nanoseconds(-999_999_999));
@@ -765,7 +765,7 @@ mod test {
#[test]
pub fn test_timeval() {
- assert!(TimeVal::seconds(1) != TimeVal::zero());
+ assert_ne!(TimeVal::seconds(1), TimeVal::zero());
assert_eq!(
TimeVal::seconds(1) + TimeVal::seconds(2),
TimeVal::seconds(3)
@@ -778,7 +778,7 @@ mod test {
#[test]
pub fn test_timeval_ord() {
- assert!(TimeVal::seconds(1) == TimeVal::microseconds(1_000_000));
+ assert_eq!(TimeVal::seconds(1), TimeVal::microseconds(1_000_000));
assert!(TimeVal::seconds(1) < TimeVal::microseconds(1_000_001));
assert!(TimeVal::seconds(1) > TimeVal::microseconds(999_999));
assert!(TimeVal::seconds(-1) < TimeVal::microseconds(-999_999));
diff --git a/src/unistd.rs b/src/unistd.rs
index 70a06b02..69419d64 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -7,15 +7,15 @@ use crate::fcntl::{at_rawfd, AtFlags};
#[cfg(feature = "fs")]
use crate::fcntl::{fcntl, FcntlArg::F_SETFD, FdFlag, OFlag};
#[cfg(all(
- feature = "fs",
- any(
- target_os = "openbsd",
- target_os = "netbsd",
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "macos",
- target_os = "ios"
- )
+feature = "fs",
+any(
+target_os = "openbsd",
+target_os = "netbsd",
+target_os = "freebsd",
+target_os = "dragonfly",
+target_os = "macos",
+target_os = "ios"
+)
))]
use crate::sys::stat::FileFlag;
#[cfg(feature = "fs")]
@@ -45,20 +45,20 @@ feature! {
}
#[cfg(any(
- target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "linux",
- target_os = "openbsd"
+target_os = "android",
+target_os = "dragonfly",
+target_os = "freebsd",
+target_os = "linux",
+target_os = "openbsd"
))]
pub use self::setres::*;
#[cfg(any(
- target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "linux",
- target_os = "openbsd"
+target_os = "android",
+target_os = "dragonfly",
+target_os = "freebsd",
+target_os = "linux",
+target_os = "openbsd"
))]
pub use self::getres::*;
@@ -1572,7 +1572,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
/// # use std::error::Error;
/// # use nix::unistd::*;
/// #
-/// # fn try_main() -> Result<(), Box<Error>> {
+/// # fn try_main() -> Result<(), Box<dyn Error>> {
/// let uid = Uid::from_raw(33);
/// let gid = Gid::from_raw(34);
/// setgroups(&[gid])?;
@@ -1698,7 +1698,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
/// # use std::ffi::CString;
/// # use nix::unistd::*;
/// #
-/// # fn try_main() -> Result<(), Box<Error>> {
+/// # fn try_main() -> Result<(), Box<dyn Error>> {
/// let user = CString::new("www-data").unwrap();
/// let uid = Uid::from_raw(33);
/// let gid = Gid::from_raw(33);
@@ -2752,11 +2752,11 @@ mod pivot_root {
}
#[cfg(any(
- target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "linux",
- target_os = "openbsd"
+target_os = "android",
+target_os = "dragonfly",
+target_os = "freebsd",
+target_os = "linux",
+target_os = "openbsd"
))]
mod setres {
feature! {
@@ -2801,11 +2801,11 @@ mod setres {
}
#[cfg(any(
- target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "linux",
- target_os = "openbsd"
+target_os = "android",
+target_os = "dragonfly",
+target_os = "freebsd",
+target_os = "linux",
+target_os = "openbsd"
))]
mod getres {
feature! {
@@ -3121,7 +3121,7 @@ impl User {
/// use nix::unistd::{Uid, User};
/// // Returns an Result<Option<User>>, thus the double unwrap.
/// let res = User::from_uid(Uid::from_raw(0)).unwrap().unwrap();
- /// assert!(res.name == "root");
+ /// assert_eq!(res.name, "root");
/// ```
pub fn from_uid(uid: Uid) -> Result<Option<Self>> {
User::from_anything(|pwd, cbuf, cap, res| {
@@ -3140,7 +3140,7 @@ impl User {
/// use nix::unistd::User;
/// // Returns an Result<Option<User>>, thus the double unwrap.
/// let res = User::from_name("root").unwrap().unwrap();
- /// assert!(res.name == "root");
+ /// assert_eq!(res.name, "root");
/// ```
pub fn from_name(name: &str) -> Result<Option<Self>> {
let name = CString::new(name).unwrap();