Skip to content

Commit 9abb3f4

Browse files
authored
Merge pull request #163 from epage/edition
chore: Migrate to Edition 2024
2 parents 59f2db4 + 42d2091 commit 9abb3f4

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[workspace]
2-
resolver = "2"
2+
resolver = "3"
33

44
[workspace.package]
55
repository = "https://github.com/rust-cli/rexpect"
66
license = "MIT OR Apache-2.0"
7-
edition = "2021"
8-
rust-version = "1.70.0" # MSRV
7+
edition = "2024"
8+
rust-version = "1.85.0" # MSRV
99
include = [
1010
"build.rs",
1111
"src/**/*",

src/process.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
33
use crate::error::Error;
44
use nix;
5-
use nix::fcntl::{open, OFlag};
5+
use nix::fcntl::{OFlag, open};
66
use nix::libc::STDERR_FILENO;
7-
use nix::pty::{grantpt, posix_openpt, unlockpt, PtyMaster};
7+
use nix::pty::{PtyMaster, grantpt, posix_openpt, unlockpt};
88
pub use nix::sys::{signal, wait};
99
use nix::sys::{stat, termios};
1010
use nix::unistd::{
11-
close, dup, dup2_stderr, dup2_stdin, dup2_stdout, fork, setsid, ForkResult, Pid,
11+
ForkResult, Pid, close, dup, dup2_stderr, dup2_stdin, dup2_stdout, fork, setsid,
1212
};
1313
use std;
1414
use std::fs::File;
@@ -68,7 +68,7 @@ use nix::pty::ptsname_r;
6868
/// instead of using a static mutex this calls ioctl with TIOCPTYGNAME directly
6969
/// based on https://blog.tarq.io/ptsname-on-osx-with-rust/
7070
fn ptsname_r(fd: &PtyMaster) -> nix::Result<String> {
71-
use nix::libc::{ioctl, TIOCPTYGNAME};
71+
use nix::libc::{TIOCPTYGNAME, ioctl};
7272
use std::ffi::CStr;
7373

7474
// the buffer size on OSX is 128, defined by sys/ttycom.h
@@ -207,7 +207,7 @@ impl PtyProcess {
207207
Ok(_) => {}
208208
// process was already killed before -> ignore
209209
Err(nix::errno::Errno::ESRCH) => {
210-
return Ok(wait::WaitStatus::Exited(Pid::from_raw(0), 0))
210+
return Ok(wait::WaitStatus::Exited(Pid::from_raw(0), 0));
211211
}
212212
Err(e) => return Err(Error::from(e)),
213213
}

src/reader.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::error::Error;
44
pub use regex::Regex;
55
use std::io::prelude::*;
66
use std::io::{self, BufReader};
7-
use std::sync::mpsc::{channel, Receiver};
7+
use std::sync::mpsc::{Receiver, channel};
88
use std::thread;
99
use std::{fmt, time};
1010

@@ -31,13 +31,13 @@ pub enum ReadUntil {
3131
impl fmt::Display for ReadUntil {
3232
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3333
let printable = match self {
34-
ReadUntil::String(ref s) if s == "\n" => "\\n (newline)".to_owned(),
35-
ReadUntil::String(ref s) if s == "\r" => "\\r (carriage return)".to_owned(),
36-
ReadUntil::String(ref s) => format!("\"{s}\""),
37-
ReadUntil::Regex(ref r) => format!("Regex: \"{r}\""),
34+
ReadUntil::String(s) if s == "\n" => "\\n (newline)".to_owned(),
35+
ReadUntil::String(s) if s == "\r" => "\\r (carriage return)".to_owned(),
36+
ReadUntil::String(s) => format!("\"{s}\""),
37+
ReadUntil::Regex(r) => format!("Regex: \"{r}\""),
3838
ReadUntil::EOF => "EOF (End of File)".to_owned(),
3939
ReadUntil::NBytes(n) => format!("reading {n} bytes"),
40-
ReadUntil::Any(ref v) => {
40+
ReadUntil::Any(v) => {
4141
let mut res = Vec::new();
4242
for r in v {
4343
res.push(r.to_string());
@@ -63,8 +63,8 @@ impl fmt::Display for ReadUntil {
6363
/// 2. position after match
6464
pub fn find(needle: &ReadUntil, buffer: &str, eof: bool) -> Option<(usize, usize)> {
6565
match needle {
66-
ReadUntil::String(ref s) => buffer.find(s).map(|pos| (pos, pos + s.len())),
67-
ReadUntil::Regex(ref pattern) => pattern.find(buffer).map(|mat| (mat.start(), mat.end())),
66+
ReadUntil::String(s) => buffer.find(s).map(|pos| (pos, pos + s.len())),
67+
ReadUntil::Regex(pattern) => pattern.find(buffer).map(|mat| (mat.start(), mat.end())),
6868
ReadUntil::EOF => {
6969
if eof {
7070
Some((0, buffer.len()))
@@ -83,7 +83,7 @@ pub fn find(needle: &ReadUntil, buffer: &str, eof: bool) -> Option<(usize, usize
8383
None
8484
}
8585
}
86-
ReadUntil::Any(ref anys) => anys
86+
ReadUntil::Any(anys) => anys
8787
.iter()
8888
// Filter matching needles
8989
.filter_map(|any| find(any, buffer, eof))

src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::process::PtyProcess;
55
use crate::reader::{NBReader, Regex};
66
pub use crate::reader::{Options, ReadUntil};
77
use std::fs::File;
8-
use std::io::prelude::*;
98
use std::io::LineWriter;
9+
use std::io::prelude::*;
1010
use std::ops::{Deref, DerefMut};
1111
use std::process::Command;
1212
use tempfile;

0 commit comments

Comments
 (0)