Auto merge of #10222 - faineance:master, r=KiChjang

Use self.0 instead of destructuring single item tuple structs.

Closes #9698.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10222)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-28 04:12:31 +05:30
commit b97ffffb48
17 changed files with 37 additions and 71 deletions

View file

@ -394,9 +394,8 @@ impl CORSCache {
header_name: &str)
-> Option<&'a mut CORSCacheEntry> {
self.cleanup();
let CORSCache(ref mut buf) = *self;
// Credentials are not yet implemented here
buf.iter_mut().find(|e| {
self.0.iter_mut().find(|e| {
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
e.origin.port() == request.origin.port() && e.url == request.destination &&
e.header_or_method.match_header(header_name)
@ -421,9 +420,8 @@ impl CORSCache {
-> Option<&'a mut CORSCacheEntry> {
// we can take the method from CORSRequest itself
self.cleanup();
let CORSCache(ref mut buf) = *self;
// Credentials are not yet implemented here
buf.iter_mut().find(|e| {
self.0.iter_mut().find(|e| {
e.origin.scheme == request.origin.scheme && e.origin.host() == request.origin.host() &&
e.origin.port() == request.origin.port() && e.url == request.destination &&
e.header_or_method.match_method(method)
@ -445,8 +443,7 @@ impl CORSCache {
fn insert(&mut self, entry: CORSCacheEntry) {
self.cleanup();
let CORSCache(ref mut buf) = *self;
buf.push(entry);
self.0.push(entry);
}
}

View file

@ -58,8 +58,7 @@ impl Into<Vec<u8>> for ByteString {
impl Hash for ByteString {
fn hash<H: Hasher>(&self, state: &mut H) {
let ByteString(ref vec) = *self;
vec.hash(state);
self.0.hash(state);
}
}

View file

@ -321,13 +321,11 @@ pub struct SendableMainThreadScriptChan(pub Sender<CommonScriptMsg>);
impl ScriptChan for SendableMainThreadScriptChan {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let SendableMainThreadScriptChan(ref chan) = *self;
chan.send(msg).map_err(|_| ())
self.0.send(msg).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let SendableMainThreadScriptChan(ref chan) = *self;
box SendableMainThreadScriptChan((*chan).clone())
box SendableMainThreadScriptChan((&self.0).clone())
}
}
@ -345,13 +343,11 @@ pub struct MainThreadScriptChan(pub Sender<MainThreadScriptMsg>);
impl ScriptChan for MainThreadScriptChan {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let MainThreadScriptChan(ref chan) = *self;
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let MainThreadScriptChan(ref chan) = *self;
box MainThreadScriptChan((*chan).clone())
box MainThreadScriptChan((&self.0).clone())
}
}

View file

@ -16,13 +16,11 @@ pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
fn queue(&self, msg: DOMManipulationTask) -> Result<(), ()> {
let DOMManipulationTaskSource(ref chan) = *self;
chan.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
let DOMManipulationTaskSource(ref chan) = *self;
box DOMManipulationTaskSource((*chan).clone())
box DOMManipulationTaskSource((&self.0).clone())
}
}

View file

@ -10,12 +10,10 @@ pub struct FileReadingTaskSource(pub Sender<MainThreadScriptMsg>);
impl ScriptChan for FileReadingTaskSource {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let FileReadingTaskSource(ref chan) = *self;
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let FileReadingTaskSource(ref chan) = *self;
box FileReadingTaskSource((*chan).clone())
box FileReadingTaskSource((&self.0).clone())
}
}

View file

@ -10,12 +10,10 @@ pub struct HistoryTraversalTaskSource(pub Sender<MainThreadScriptMsg>);
impl ScriptChan for HistoryTraversalTaskSource {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let HistoryTraversalTaskSource(ref chan) = *self;
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let HistoryTraversalTaskSource(ref chan) = *self;
box HistoryTraversalTaskSource((*chan).clone())
box HistoryTraversalTaskSource((&self.0).clone())
}
}

View file

@ -10,12 +10,10 @@ pub struct NetworkingTaskSource(pub Sender<MainThreadScriptMsg>);
impl ScriptChan for NetworkingTaskSource {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let NetworkingTaskSource(ref chan) = *self;
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let NetworkingTaskSource(ref chan) = *self;
box NetworkingTaskSource((*chan).clone())
box NetworkingTaskSource((&self.0).clone())
}
}

View file

@ -10,12 +10,10 @@ pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
impl ScriptChan for UserInteractionTaskSource {
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> {
let UserInteractionTaskSource(ref chan) = *self;
chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
self.0.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ())
}
fn clone(&self) -> Box<ScriptChan + Send> {
let UserInteractionTaskSource(ref chan) = *self;
box UserInteractionTaskSource((*chan).clone())
box UserInteractionTaskSource((&self.0).clone())
}
}