mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Use str::parse() rather than FromStr::from_str.
The former appears to be preferred.
This commit is contained in:
parent
3ece6bc166
commit
b49bd79625
5 changed files with 10 additions and 17 deletions
|
@ -34,7 +34,6 @@ use std::borrow::ToOwned;
|
|||
use std::cmp::{max, min};
|
||||
use std::collections::LinkedList;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use string_cache::Atom;
|
||||
|
@ -720,13 +719,10 @@ pub struct TableColumnFragmentInfo {
|
|||
impl TableColumnFragmentInfo {
|
||||
/// Create the information specific to an table column fragment.
|
||||
pub fn new(node: &ThreadSafeLayoutNode) -> TableColumnFragmentInfo {
|
||||
let span = {
|
||||
let element = node.as_element();
|
||||
element.get_attr(&ns!(""), &atom!("span")).and_then(|string| {
|
||||
let n: Option<u32> = FromStr::from_str(string).ok();
|
||||
n
|
||||
}).unwrap_or(0)
|
||||
};
|
||||
let span = element.get_attr(&ns!(""), &atom!("span"))
|
||||
.and_then(|string| string.parse().ok())
|
||||
.unwrap_or(0);
|
||||
TableColumnFragmentInfo {
|
||||
span: span,
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ use time::{Tm, now, at, Duration};
|
|||
use url::Url;
|
||||
use std::borrow::ToOwned;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::str::FromStr;
|
||||
|
||||
/// 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,
|
||||
|
@ -128,8 +127,8 @@ impl Cookie {
|
|||
}
|
||||
if string.ends_with(domain_string)
|
||||
&& string.as_bytes()[string.len()-domain_string.len()-1] == b'.'
|
||||
&& Ipv4Addr::from_str(string).is_err()
|
||||
&& Ipv6Addr::from_str(string).is_err() {
|
||||
&& string.parse::<Ipv4Addr>().is_err()
|
||||
&& string.parse::<Ipv6Addr>().is_err() {
|
||||
return true;
|
||||
}
|
||||
false
|
||||
|
|
|
@ -184,7 +184,7 @@ impl Request {
|
|||
}
|
||||
// Step 2
|
||||
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
|
||||
// Step 3
|
||||
|
|
|
@ -28,7 +28,6 @@ use std::collections::HashMap;
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
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,
|
||||
&partial_body).map(|(toplevel, sublevel)| {
|
||||
let mime_tp: TopLevel = FromStr::from_str(&toplevel).unwrap();
|
||||
let mime_sb: SubLevel = FromStr::from_str(&sublevel).unwrap();
|
||||
let mime_tp: TopLevel = toplevel.parse().unwrap();
|
||||
let mime_sb: SubLevel = sublevel.parse().unwrap();
|
||||
ContentType(Mime(mime_tp, mime_sb, vec!()))
|
||||
});
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ use std::ascii::AsciiExt;
|
|||
use std::borrow::ToOwned;
|
||||
use std::cell::{RefCell, Cell};
|
||||
use std::default::Default;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Mutex, Arc};
|
||||
use std::sync::mpsc::{channel, Sender, TryRecvError};
|
||||
use std::thread::sleep_ms;
|
||||
|
@ -634,7 +633,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method
|
||||
fn GetResponseHeader(self, name: ByteString) -> Option<ByteString> {
|
||||
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| {
|
||||
ByteString::new(h.value_string().into_bytes())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue