Use str::parse() rather than FromStr::from_str.

The former appears to be preferred.
This commit is contained in:
Ms2ger 2015-06-10 14:36:36 +02:00
parent 3ece6bc166
commit b49bd79625
5 changed files with 10 additions and 17 deletions

View file

@ -34,7 +34,6 @@ use std::borrow::ToOwned;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::collections::LinkedList; use std::collections::LinkedList;
use std::fmt; use std::fmt;
use std::str::FromStr;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use string_cache::Atom; use string_cache::Atom;
@ -720,13 +719,10 @@ pub struct TableColumnFragmentInfo {
impl TableColumnFragmentInfo { impl TableColumnFragmentInfo {
/// Create the information specific to an table column fragment. /// Create the information specific to an table column fragment.
pub fn new(node: &ThreadSafeLayoutNode) -> TableColumnFragmentInfo { pub fn new(node: &ThreadSafeLayoutNode) -> TableColumnFragmentInfo {
let span = { let element = node.as_element();
let element = node.as_element(); let span = element.get_attr(&ns!(""), &atom!("span"))
element.get_attr(&ns!(""), &atom!("span")).and_then(|string| { .and_then(|string| string.parse().ok())
let n: Option<u32> = FromStr::from_str(string).ok(); .unwrap_or(0);
n
}).unwrap_or(0)
};
TableColumnFragmentInfo { TableColumnFragmentInfo {
span: span, span: span,
} }

View file

@ -13,7 +13,6 @@ use time::{Tm, now, at, Duration};
use url::Url; use url::Url;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::net::{Ipv4Addr, Ipv6Addr}; use std::net::{Ipv4Addr, Ipv6Addr};
use std::str::FromStr;
/// A stored cookie that wraps the definition in cookie-rs. This is used to implement /// A stored cookie that wraps the definition in cookie-rs. This is used to implement
/// various behaviours defined in the spec that rely on an associated request URL, /// various behaviours defined in the spec that rely on an associated request URL,
@ -128,8 +127,8 @@ impl Cookie {
} }
if string.ends_with(domain_string) if string.ends_with(domain_string)
&& string.as_bytes()[string.len()-domain_string.len()-1] == b'.' && string.as_bytes()[string.len()-domain_string.len()-1] == b'.'
&& Ipv4Addr::from_str(string).is_err() && string.parse::<Ipv4Addr>().is_err()
&& Ipv6Addr::from_str(string).is_err() { && string.parse::<Ipv6Addr>().is_err() {
return true; return true;
} }
false false

View file

@ -184,7 +184,7 @@ impl Request {
} }
// Step 2 // Step 2
if self.context != Context::Fetch && !self.headers.has::<AcceptLanguage>() { if self.context != Context::Fetch && !self.headers.has::<AcceptLanguage>() {
self.headers.set(AcceptLanguage(vec![qitem(Language::from_str("en-US").unwrap())])); self.headers.set(AcceptLanguage(vec![qitem("en-US".parse().unwrap())]));
} }
// TODO: Figure out what a Priority object is // TODO: Figure out what a Priority object is
// Step 3 // Step 3

View file

@ -28,7 +28,6 @@ use std::collections::HashMap;
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::{BufReader, Read}; use std::io::{BufReader, Read};
use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::mpsc::{channel, Receiver, Sender};
@ -122,8 +121,8 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat
}); });
metadata.content_type = classifier.classify(nosniff, check_for_apache_bug, &supplied_type, metadata.content_type = classifier.classify(nosniff, check_for_apache_bug, &supplied_type,
&partial_body).map(|(toplevel, sublevel)| { &partial_body).map(|(toplevel, sublevel)| {
let mime_tp: TopLevel = FromStr::from_str(&toplevel).unwrap(); let mime_tp: TopLevel = toplevel.parse().unwrap();
let mime_sb: SubLevel = FromStr::from_str(&sublevel).unwrap(); let mime_sb: SubLevel = sublevel.parse().unwrap();
ContentType(Mime(mime_tp, mime_sb, vec!())) ContentType(Mime(mime_tp, mime_sb, vec!()))
}); });

View file

@ -56,7 +56,6 @@ use std::ascii::AsciiExt;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::{RefCell, Cell}; use std::cell::{RefCell, Cell};
use std::default::Default; use std::default::Default;
use std::str::FromStr;
use std::sync::{Mutex, Arc}; use std::sync::{Mutex, Arc};
use std::sync::mpsc::{channel, Sender, TryRecvError}; use std::sync::mpsc::{channel, Sender, TryRecvError};
use std::thread::sleep_ms; use std::thread::sleep_ms;
@ -634,7 +633,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method // https://xhr.spec.whatwg.org/#the-getresponseheader()-method
fn GetResponseHeader(self, name: ByteString) -> Option<ByteString> { fn GetResponseHeader(self, name: ByteString) -> Option<ByteString> {
self.filter_response_headers().iter().find(|h| { self.filter_response_headers().iter().find(|h| {
name.eq_ignore_case(&FromStr::from_str(h.name()).unwrap()) name.eq_ignore_case(&h.name().parse().unwrap())
}).map(|h| { }).map(|h| {
ByteString::new(h.value_string().into_bytes()) ByteString::new(h.value_string().into_bytes())
}) })