From 5cfa555c0b9fb4a02b3c0546dbd74b0b7b6d1aca Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 2 Mar 2026 15:50:57 -0600 Subject: [PATCH 1/2] chore: Bump MSRV to 1.85 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e61c83fd..6003e829 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" repository = "https://github.com/rust-cli/rexpect" license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70.0" # MSRV +rust-version = "1.85.0" # MSRV include = [ "build.rs", "src/**/*", From 42d20910fdf9b8b47ece35c0d914908ff9b4268c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 2 Mar 2026 15:51:34 -0600 Subject: [PATCH 2/2] chore: Migrate to Edition 2024 --- Cargo.toml | 4 ++-- src/process.rs | 10 +++++----- src/reader.rs | 18 +++++++++--------- src/session.rs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6003e829..f14f85cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [workspace] -resolver = "2" +resolver = "3" [workspace.package] repository = "https://github.com/rust-cli/rexpect" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85.0" # MSRV include = [ "build.rs", diff --git a/src/process.rs b/src/process.rs index 63cfb498..db1c2507 100644 --- a/src/process.rs +++ b/src/process.rs @@ -2,13 +2,13 @@ use crate::error::Error; use nix; -use nix::fcntl::{open, OFlag}; +use nix::fcntl::{OFlag, open}; use nix::libc::STDERR_FILENO; -use nix::pty::{grantpt, posix_openpt, unlockpt, PtyMaster}; +use nix::pty::{PtyMaster, grantpt, posix_openpt, unlockpt}; pub use nix::sys::{signal, wait}; use nix::sys::{stat, termios}; use nix::unistd::{ - close, dup, dup2_stderr, dup2_stdin, dup2_stdout, fork, setsid, ForkResult, Pid, + ForkResult, Pid, close, dup, dup2_stderr, dup2_stdin, dup2_stdout, fork, setsid, }; use std; use std::fs::File; @@ -68,7 +68,7 @@ use nix::pty::ptsname_r; /// instead of using a static mutex this calls ioctl with TIOCPTYGNAME directly /// based on https://blog.tarq.io/ptsname-on-osx-with-rust/ fn ptsname_r(fd: &PtyMaster) -> nix::Result { - use nix::libc::{ioctl, TIOCPTYGNAME}; + use nix::libc::{TIOCPTYGNAME, ioctl}; use std::ffi::CStr; // the buffer size on OSX is 128, defined by sys/ttycom.h @@ -207,7 +207,7 @@ impl PtyProcess { Ok(_) => {} // process was already killed before -> ignore Err(nix::errno::Errno::ESRCH) => { - return Ok(wait::WaitStatus::Exited(Pid::from_raw(0), 0)) + return Ok(wait::WaitStatus::Exited(Pid::from_raw(0), 0)); } Err(e) => return Err(Error::from(e)), } diff --git a/src/reader.rs b/src/reader.rs index 7a6a9443..a6ae6e54 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4,7 +4,7 @@ use crate::error::Error; pub use regex::Regex; use std::io::prelude::*; use std::io::{self, BufReader}; -use std::sync::mpsc::{channel, Receiver}; +use std::sync::mpsc::{Receiver, channel}; use std::thread; use std::{fmt, time}; @@ -31,13 +31,13 @@ pub enum ReadUntil { impl fmt::Display for ReadUntil { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let printable = match self { - ReadUntil::String(ref s) if s == "\n" => "\\n (newline)".to_owned(), - ReadUntil::String(ref s) if s == "\r" => "\\r (carriage return)".to_owned(), - ReadUntil::String(ref s) => format!("\"{s}\""), - ReadUntil::Regex(ref r) => format!("Regex: \"{r}\""), + ReadUntil::String(s) if s == "\n" => "\\n (newline)".to_owned(), + ReadUntil::String(s) if s == "\r" => "\\r (carriage return)".to_owned(), + ReadUntil::String(s) => format!("\"{s}\""), + ReadUntil::Regex(r) => format!("Regex: \"{r}\""), ReadUntil::EOF => "EOF (End of File)".to_owned(), ReadUntil::NBytes(n) => format!("reading {n} bytes"), - ReadUntil::Any(ref v) => { + ReadUntil::Any(v) => { let mut res = Vec::new(); for r in v { res.push(r.to_string()); @@ -63,8 +63,8 @@ impl fmt::Display for ReadUntil { /// 2. position after match pub fn find(needle: &ReadUntil, buffer: &str, eof: bool) -> Option<(usize, usize)> { match needle { - ReadUntil::String(ref s) => buffer.find(s).map(|pos| (pos, pos + s.len())), - ReadUntil::Regex(ref pattern) => pattern.find(buffer).map(|mat| (mat.start(), mat.end())), + ReadUntil::String(s) => buffer.find(s).map(|pos| (pos, pos + s.len())), + ReadUntil::Regex(pattern) => pattern.find(buffer).map(|mat| (mat.start(), mat.end())), ReadUntil::EOF => { if eof { Some((0, buffer.len())) @@ -83,7 +83,7 @@ pub fn find(needle: &ReadUntil, buffer: &str, eof: bool) -> Option<(usize, usize None } } - ReadUntil::Any(ref anys) => anys + ReadUntil::Any(anys) => anys .iter() // Filter matching needles .filter_map(|any| find(any, buffer, eof)) diff --git a/src/session.rs b/src/session.rs index 52f2f41b..07399812 100644 --- a/src/session.rs +++ b/src/session.rs @@ -5,8 +5,8 @@ use crate::process::PtyProcess; use crate::reader::{NBReader, Regex}; pub use crate::reader::{Options, ReadUntil}; use std::fs::File; -use std::io::prelude::*; use std::io::LineWriter; +use std::io::prelude::*; use std::ops::{Deref, DerefMut}; use std::process::Command; use tempfile;