diff --git a/src/client/stream.rs b/src/client/stream.rs index 10b9e1b..472c15a 100644 --- a/src/client/stream.rs +++ b/src/client/stream.rs @@ -72,7 +72,7 @@ impl ClientStream for TcpStream { fn get_reply(&mut self) -> SmtpResult { let response = try!(self.read_into_string()); - match from_str::(response.as_slice()) { + match response.as_slice().parse::() { Some(response) => Ok(response), None => Err(FromError::from_error("Could not parse response")) } diff --git a/src/extension.rs b/src/extension.rs index 3fd2a5b..aebc28f 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -63,7 +63,7 @@ impl FromStr for Extension { "STARTTLS" => Some(StartTls), _ => None, }, - 2 => match (splitted[0], from_str::(splitted[1])) { + 2 => match (splitted[0], splitted[1].parse::()) { ("SIZE", Some(size)) => Some(Size(size)), _ => None, }, @@ -88,8 +88,8 @@ impl Extension { pub fn parse_esmtp_response(message: &str) -> Option> { let mut esmtp_features = Vec::new(); for line in message.split_str(CRLF) { - if let Some(Response{code: 250, message}) = from_str::(line) { - if let Some(keyword) = from_str::(message.unwrap().as_slice()) { + if let Some(Response{code: 250, message}) = line.parse::() { + if let Some(keyword) = message.unwrap().as_slice().parse::() { esmtp_features.push(keyword); }; } diff --git a/src/response.rs b/src/response.rs index ef0f8fc..3a1c5af 100644 --- a/src/response.rs +++ b/src/response.rs @@ -45,7 +45,7 @@ impl FromStr for Response { None // If we have only a code, with or without a trailing space } else if s.len() == 3 || (s.len() == 4 && s.slice(3,4) == " ") { - match from_str::(s.slice_to(3)) { + match s.slice_to(3).parse::() { Some(code) => Some(Response{ code: code, message: None @@ -55,7 +55,7 @@ impl FromStr for Response { // If we have a code and a message } else { match ( - from_str::(s.slice_to(3)), + s.slice_to(3).parse::(), vec![" ", "-"].contains(&s.slice(3,4)), (remove_trailing_crlf(s.slice_from(4))) ) { diff --git a/src/tools.rs b/src/tools.rs index d9a065e..c171a6e 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -10,7 +10,6 @@ //! Tools for common string manipulations use std::string::String; -use std::str::replace; use common::{CR, LF, CRLF}; @@ -35,7 +34,7 @@ pub fn get_first_word(string: &str) -> &str { /// Returns the string replacing all the CRLF with "\" #[inline] pub fn escape_crlf(string: &str) -> String { - replace(string, CRLF, "") + string.replace(CRLF, "") } /// Returns the string after adding a dot at the beginning of each line starting with a dot