diff --git a/src/buffer_line.rs b/src/buffer_line.rs index 0800707..44b9e0a 100644 --- a/src/buffer_line.rs +++ b/src/buffer_line.rs @@ -1,5 +1,6 @@ #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; +use core::mem; use crate::{ Align, Attrs, AttrsList, Cached, FontSystem, LayoutLine, LineEnding, ShapeBuffer, ShapeLine, @@ -327,14 +328,14 @@ impl BufferLine { /// /// The buffer line is in an invalid state after this is called. See [`Self::reset_new`]. pub(crate) fn reclaim_attrs(&mut self) -> AttrsList { - std::mem::replace(&mut self.attrs_list, AttrsList::new(Attrs::new())) + mem::replace(&mut self.attrs_list, AttrsList::new(Attrs::new())) } /// Reclaim text memory that isn't needed any longer. /// /// The buffer line is in an invalid state after this is called. See [`Self::reset_new`]. pub(crate) fn reclaim_text(&mut self) -> String { - let mut text = std::mem::take(&mut self.text); + let mut text = mem::take(&mut self.text); text.clear(); text } diff --git a/src/cached.rs b/src/cached.rs index 0cea7c6..7e26612 100644 --- a/src/cached.rs +++ b/src/cached.rs @@ -1,4 +1,5 @@ use core::fmt::Debug; +use core::mem; /// Helper for caching a value when the value is optionally present in the 'unused' state. #[derive(Clone, Debug)] @@ -44,7 +45,7 @@ impl Cached { /// Takes the buffered value if in state `Self::Unused`. pub fn take_unused(&mut self) -> Option { if matches!(*self, Self::Unused(_)) { - let Self::Unused(val) = std::mem::replace(self, Self::Empty) else { + let Self::Unused(val) = mem::replace(self, Self::Empty) else { unreachable!() }; Some(val) @@ -56,7 +57,7 @@ impl Cached { /// Takes the cached value if in state `Self::Used`. pub fn take_used(&mut self) -> Option { if matches!(*self, Self::Used(_)) { - let Self::Used(val) = std::mem::replace(self, Self::Empty) else { + let Self::Used(val) = mem::replace(self, Self::Empty) else { unreachable!() }; Some(val) diff --git a/src/shape.rs b/src/shape.rs index b13ec1e..0afb5ba 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -632,7 +632,7 @@ impl ShapeWord { word ); - let mut glyphs = std::mem::take(&mut self.glyphs); + let mut glyphs = mem::take(&mut self.glyphs); glyphs.clear(); let span_rtl = level.is_rtl(); @@ -771,10 +771,10 @@ impl ShapeSpan { span ); - let mut words = std::mem::take(&mut self.words); + let mut words = mem::take(&mut self.words); // Cache the shape words in reverse order so they can be popped for reuse in the same order. - let mut cached_words = std::mem::take(&mut scratch.words); + let mut cached_words = mem::take(&mut scratch.words); cached_words.clear(); if line_rtl != level.is_rtl() { // Un-reverse previous words so the internal glyph counts match accurately when rewriting memory. @@ -941,10 +941,10 @@ impl ShapeLine { shaping: Shaping, tab_width: u16, ) { - let mut spans = std::mem::take(&mut self.spans); + let mut spans = mem::take(&mut self.spans); // Cache the shape spans in reverse order so they can be popped for reuse in the same order. - let mut cached_spans = std::mem::take(&mut scratch.spans); + let mut cached_spans = mem::take(&mut scratch.spans); cached_spans.clear(); cached_spans.extend(spans.drain(..).rev());