mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use the Deref traits for FlowRefs.
This patch switches FlowRefs to using the Deref and DerefMut traits, instead of the custom `get` and `get_mut` functions.
This commit is contained in:
parent
afc144aa39
commit
76ed7484eb
10 changed files with 76 additions and 74 deletions
|
@ -39,25 +39,25 @@ impl FlowList {
|
|||
/// Provide a reference to the front element, or None if the list is empty
|
||||
#[inline]
|
||||
pub fn front<'a>(&'a self) -> Option<&'a Flow> {
|
||||
self.flows.front().map(|head| head.get())
|
||||
self.flows.front().map(|head| head.deref())
|
||||
}
|
||||
|
||||
/// Provide a mutable reference to the front element, or None if the list is empty
|
||||
#[inline]
|
||||
pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
||||
self.flows.front_mut().map(|head| head.get_mut())
|
||||
self.flows.front_mut().map(|head| head.deref_mut())
|
||||
}
|
||||
|
||||
/// Provide a reference to the back element, or None if the list is empty
|
||||
#[inline]
|
||||
pub fn back<'a>(&'a self) -> Option<&'a Flow> {
|
||||
self.flows.back().map(|tail| tail.get())
|
||||
self.flows.back().map(|tail| tail.deref())
|
||||
}
|
||||
|
||||
/// Provide a mutable reference to the back element, or None if the list is empty
|
||||
#[inline]
|
||||
pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
|
||||
self.flows.back_mut().map(|tail| tail.get_mut())
|
||||
self.flows.back_mut().map(|tail| tail.deref_mut())
|
||||
}
|
||||
|
||||
/// Add an element first in the list
|
||||
|
@ -109,7 +109,7 @@ impl FlowList {
|
|||
impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a Flow + 'a> {
|
||||
self.it.next().map(|x| x.get())
|
||||
self.it.next().map(|x| x.deref())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -121,7 +121,7 @@ impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> {
|
|||
impl<'a> Iterator<&'a mut Flow + 'a> for MutFlowListIterator<'a> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<&'a mut Flow + 'a> {
|
||||
self.it.next().map(|x| x.get_mut())
|
||||
self.it.next().map(|x| x.deref_mut())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue