Issue 3223: reformat via cargo fmt
This commit is contained in:
@@ -211,34 +211,36 @@ impl<T: RawBlockTraits> SerialOffsetTable<T> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn build_with(&mut self, value: T) -> usize { unsafe {
|
unsafe fn build_with(&mut self, value: T) -> usize {
|
||||||
let mut ptr;
|
unsafe {
|
||||||
|
let mut ptr;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ptr = self.block.alloc(size_of::<T>());
|
ptr = self.block.alloc(size_of::<T>());
|
||||||
|
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
let new_block = self.block.grow_new().unwrap();
|
let new_block = self.block.grow_new().unwrap();
|
||||||
self.block = new_block;
|
self.block = new_block;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptr::write(ptr as *mut T, value);
|
||||||
|
// SAFETY: `ptr` was obtained from `self.block.alloc()`
|
||||||
|
self.block.get_offset(ptr)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ptr::write(ptr as *mut T, value);
|
|
||||||
// SAFETY: `ptr` was obtained from `self.block.alloc()`
|
|
||||||
self.block.get_offset(ptr)
|
|
||||||
}}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn lookup(&self, offset: usize) -> &T { unsafe {
|
unsafe fn lookup(&self, offset: usize) -> &T {
|
||||||
&*self.block.get_unchecked(offset).cast::<T>()
|
unsafe { &*self.block.get_unchecked(offset).cast::<T>() }
|
||||||
}}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T { unsafe {
|
unsafe fn lookup_mut(&mut self, offset: usize) -> &mut T {
|
||||||
&mut *self.block.get_unchecked(offset).cast::<T>().cast_mut()
|
unsafe { &mut *self.block.get_unchecked(offset).cast::<T>().cast_mut() }
|
||||||
}}
|
}
|
||||||
|
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn to_concurrent(&mut self) -> ConcurrentOffsetTable<T>
|
fn to_concurrent(&mut self) -> ConcurrentOffsetTable<T>
|
||||||
|
|||||||
Reference in New Issue
Block a user