pub fn new() -> Self {
// Ideally we'd pad `STACK_CAP` out to the alignment, avoiding wasting any
// space, but we can't do maffs with constants just yet, so abort instead.
- debug_assert!(STACK_CAP % std::mem::align_of::<PageFooter>() == 0);
+ debug_assert!(STACK_CAP.is_multiple_of(std::mem::align_of::<PageFooter>()));
+
Self {
data: MaybeUninit::uninit(),
footer: Cell::new(PageFooter {
let remainder = self.cap - self.pos;
if remainder == MAX_LINE_SIZE {
- return Err(Error::Io(std::io::Error::new(
- std::io::ErrorKind::Other,
- "line too long",
- )));
+ return Err(Error::Io(std::io::Error::other("line too long")));
}
if remainder != 0 {
pub fn remove(&mut self, handle: Handle) -> Option<T> {
let (generation, slot_index) = handle.decode(self.decode_multiplier);
- if let Some(slot) = self.slots.get_mut(slot_index) {
- if slot.generation() == generation {
- self.free_slots.push(slot_index);
- let value_index = slot.value_index();
- slot.set_value_index(ValueIndex::invalid());
- return Some(self.values.swap_remove(value_index, &mut self.slots));
- }
+ if let Some(slot) = self.slots.get_mut(slot_index)
+ && slot.generation() == generation
+ {
+ self.free_slots.push(slot_index);
+ let value_index = slot.value_index();
+ slot.set_value_index(ValueIndex::invalid());
+ return Some(self.values.swap_remove(value_index, &mut self.slots));
}
None
pub fn get_mut(&mut self, handle: Handle) -> Option<&mut T> {
let (generation, slot_index) = handle.decode(self.decode_multiplier);
- if let Some(slot) = self.slots.get(slot_index) {
- if slot.generation() == generation {
- return Some(self.values.get_mut(slot.value_index()));
- }
+ if let Some(slot) = self.slots.get(slot_index)
+ && slot.generation() == generation
+ {
+ return Some(self.values.get_mut(slot.value_index()));
}
None
pub fn get(&self, handle: Handle) -> Option<&T> {
let (generation, slot_index) = handle.decode(self.decode_multiplier);
- if let Some(slot) = self.slots.get(slot_index) {
- if slot.generation() == generation {
- return Some(self.values.get(slot.value_index()));
- }
+ if let Some(slot) = self.slots.get(slot_index)
+ && slot.generation() == generation
+ {
+ return Some(self.values.get(slot.value_index()));
}
None
SvgEnd
}
-pub fn text<T>(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text<T>
+pub fn text<T>(x: f32, y: f32, size: f32, style: Style, text: &T) -> Text<'_, T>
where
T: fmt::Display,
{
self.value.load(Ordering::Relaxed)
}
- pub fn acquire(&self, device_addr: usize) -> Frame {
+ pub fn acquire(&self, device_addr: usize) -> Frame<'_> {
let old_frame_counter = self.value.fetch_add(1, Ordering::SeqCst);
assert!(
old_frame_counter & 1 == 1,
pub const fn with_immutable_samplers(
stages: ShaderStageFlags,
immutable_samplers: &[Sampler],
- ) -> BindDesc {
+ ) -> BindDesc<'_> {
BindDesc {
slot: !0,
stages,
fn wait_idle(&self);
- fn begin_frame(&self) -> Frame;
+ fn begin_frame(&self) -> Frame<'_>;
fn end_frame<'device>(&'device self, frame: Frame<'device>);
}
}
impl PersistentBuffer<'_> {
- pub fn to_arg(&self) -> BufferArg {
+ pub fn to_arg(&self) -> BufferArg<'_> {
BufferArg::Persistent(self)
}
}
impl TransientBuffer<'_> {
- pub fn to_arg(&self) -> BufferArg {
+ pub fn to_arg(&self) -> BufferArg<'_> {
BufferArg::Transient(self)
}
}
}
- pub fn fetch(&mut self) -> Rows {
+ pub fn fetch(&mut self) -> Rows<'_> {
Rows {
statement: Some(self.statement),
}
NonZeroI32::new(index)
}
- pub fn query(&mut self) -> Query {
+ pub fn query(&mut self) -> Query<'_> {
Query { statement: self }
}
}
impl<'a> Models<'a> {
pub fn load(gpu: &'a Gpu) -> Models<'a> {
- fn load_model<P>(gpu: &Gpu, path: P) -> Model
+ fn load_model<P>(gpu: &Gpu, path: P) -> Model<'_>
where
P: AsRef<Path>,
{