@@ -4,7 +4,7 @@ use crate::error::Error;
44pub use regex:: Regex ;
55use std:: io:: prelude:: * ;
66use std:: io:: { self , BufReader } ;
7- use std:: sync:: mpsc:: { channel , Receiver } ;
7+ use std:: sync:: mpsc:: { Receiver , channel } ;
88use std:: thread;
99use std:: { fmt, time} ;
1010
@@ -31,13 +31,13 @@ pub enum ReadUntil {
3131impl 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
6464pub 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) )
0 commit comments