fix no_std
This commit is contained in:
parent
cdf1e5b4ee
commit
c65f299e87
3 changed files with 11 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<T: Clone + Debug> Cached<T> {
|
|||
/// Takes the buffered value if in state `Self::Unused`.
|
||||
pub fn take_unused(&mut self) -> Option<T> {
|
||||
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<T: Clone + Debug> Cached<T> {
|
|||
/// Takes the cached value if in state `Self::Used`.
|
||||
pub fn take_used(&mut self) -> Option<T> {
|
||||
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)
|
||||
|
|
|
|||
10
src/shape.rs
10
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());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue