Rust upgrade: fix deprecated methods.
This commit is contained in:
@@ -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>(response.as_slice()) {
|
||||
match response.as_slice().parse::<Response>() {
|
||||
Some(response) => Ok(response),
|
||||
None => Err(FromError::from_error("Could not parse response"))
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ impl FromStr for Extension {
|
||||
"STARTTLS" => Some(StartTls),
|
||||
_ => None,
|
||||
},
|
||||
2 => match (splitted[0], from_str::<uint>(splitted[1])) {
|
||||
2 => match (splitted[0], splitted[1].parse::<uint>()) {
|
||||
("SIZE", Some(size)) => Some(Size(size)),
|
||||
_ => None,
|
||||
},
|
||||
@@ -88,8 +88,8 @@ impl Extension {
|
||||
pub fn parse_esmtp_response(message: &str) -> Option<Vec<Extension>> {
|
||||
let mut esmtp_features = Vec::new();
|
||||
for line in message.split_str(CRLF) {
|
||||
if let Some(Response{code: 250, message}) = from_str::<Response>(line) {
|
||||
if let Some(keyword) = from_str::<Extension>(message.unwrap().as_slice()) {
|
||||
if let Some(Response{code: 250, message}) = line.parse::<Response>() {
|
||||
if let Some(keyword) = message.unwrap().as_slice().parse::<Extension>() {
|
||||
esmtp_features.push(keyword);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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::<u16>(s.slice_to(3)) {
|
||||
match s.slice_to(3).parse::<u16>() {
|
||||
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::<u16>(s.slice_to(3)),
|
||||
s.slice_to(3).parse::<u16>(),
|
||||
vec![" ", "-"].contains(&s.slice(3,4)),
|
||||
(remove_trailing_crlf(s.slice_from(4)))
|
||||
) {
|
||||
|
||||
@@ -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 "\<CRLF\>"
|
||||
#[inline]
|
||||
pub fn escape_crlf(string: &str) -> String {
|
||||
replace(string, CRLF, "<CR><LF>")
|
||||
string.replace(CRLF, "<CR><LF>")
|
||||
}
|
||||
|
||||
/// Returns the string after adding a dot at the beginning of each line starting with a dot
|
||||
|
||||
Reference in New Issue
Block a user