mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Fix up some unnecessary uses of unsafe
.
This commit is contained in:
parent
da02dba979
commit
94dec69247
8 changed files with 208 additions and 226 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! A persistent, thread-safe singly-linked list.
|
||||
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct PersistentList<T> {
|
||||
|
@ -81,15 +80,7 @@ impl<'a, T> Iterator for PersistentListIterator<'a, T> where T: Send + Sync + 's
|
|||
fn next(&mut self) -> Option<&'a T> {
|
||||
let entry = match self.entry {
|
||||
None => return None,
|
||||
Some(entry) => {
|
||||
// This `transmute` is necessary to ensure that the lifetimes of the next entry and
|
||||
// this entry match up; the compiler doesn't know this, but we do because of the
|
||||
// reference counting behavior of `Arc`.
|
||||
unsafe {
|
||||
mem::transmute::<&'a PersistentListEntry<T>,
|
||||
&'static PersistentListEntry<T>>(entry)
|
||||
}
|
||||
}
|
||||
Some(entry) => entry,
|
||||
};
|
||||
let value = &entry.value;
|
||||
self.entry = match entry.next {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue