pub(crate) enum OwnedFormatItemInner {
Literal(Vec<u8>),
StringLiteral(String),
Component(Component),
Compound(Vec<Self>),
Optional {
format: bool,
item: Box<Self>,
},
First(Vec<Self>),
}Variants§
Literal(Vec<u8>)
StringLiteral(String)
Component(Component)
Compound(Vec<Self>)
Optional
First(Vec<Self>)
Implementations§
Source§impl OwnedFormatItemInner
impl OwnedFormatItemInner
pub(crate) fn optimize(&mut self)
const fn no_op() -> Self
Sourcefn merge_consecutive_literals(&mut self) -> bool
fn merge_consecutive_literals(&mut self) -> bool
When there are multiple consecutive literals, they can be merged into a single literal.
As there are both UTF-8 and non-UTF-8 literals, the output is UTF-8 if and only if both literals are as well.
Sourcefn unnest_trivial_compounds(&mut self) -> bool
fn unnest_trivial_compounds(&mut self) -> bool
When a compound item only contains a single item, it can be replaced with that item.
Sourcefn unnest_nested_compounds(&mut self) -> bool
fn unnest_nested_compounds(&mut self) -> bool
When a compound item contains another compound item, the latter can be inlined into the former.
Sourcefn unnest_first_only_one(&mut self) -> bool
fn unnest_first_only_one(&mut self) -> bool
When a first item only contains a single item, it can be replaced with that item.
Sourcefn unnest_nested_first(&mut self) -> bool
fn unnest_nested_first(&mut self) -> bool
When a first item contains another first item, the latter can be inlined into the former.
Sourcefn only_formatting_uplift_optional(&mut self) -> bool
fn only_formatting_uplift_optional(&mut self) -> bool
When formatting is enabled but parsing is not, the behavior of an optional item is known ahead of time. If it is formatted, the optional item can be replaced with its inner item. If it is not formatted, it can be replace with a no-op (that will likely be removed in a later pass).
Sourcefn only_formatting_uplift_first(&mut self) -> bool
fn only_formatting_uplift_first(&mut self) -> bool
When formatting is enabled but parsing is not, the behavior of a first item is known ahead of time. It can be replaced with its first item, as the first item will always be the one that is formatted.
fn only_formatting_eliminate_end(&mut self) -> bool
Sourcefn compound_containing_empty_string(&mut self) -> bool
fn compound_containing_empty_string(&mut self) -> bool
When a compound item contains an empty string literal, it can be removed as it has no effect.
Trait Implementations§
Source§impl Clone for OwnedFormatItemInner
impl Clone for OwnedFormatItemInner
Source§fn clone(&self) -> OwnedFormatItemInner
fn clone(&self) -> OwnedFormatItemInner
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> TryFrom<(FormatDescriptionVersion, Box<[Item<'a>]>)> for OwnedFormatItemInner
impl<'a> TryFrom<(FormatDescriptionVersion, Box<[Item<'a>]>)> for OwnedFormatItemInner
Auto Trait Implementations§
impl Freeze for OwnedFormatItemInner
impl RefUnwindSafe for OwnedFormatItemInner
impl Send for OwnedFormatItemInner
impl Sync for OwnedFormatItemInner
impl Unpin for OwnedFormatItemInner
impl UnsafeUnpin for OwnedFormatItemInner
impl UnwindSafe for OwnedFormatItemInner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more