pub enum LayoutItem {
Comment(Comment),
BlankLine,
Binding {
path: SourcePath,
node: NodeId,
trailing_comment: Option<String>,
},
Section {
path: SourcePath,
trailing_comment: Option<String>,
body: SectionBody,
},
ArrayBinding {
path: SourcePath,
node: NodeId,
elements: Vec<ArrayElementLayout>,
trailing_comment: Option<String>,
},
}Expand description
An item in the layout.
Variants§
Comment(Comment)
A comment (line or block)
BlankLine
A blank line for visual separation
Binding
A key-value binding: path.to.key = <value from NodeId>
Fields
§
path: SourcePathPath to the binding target
Section
A section header: @ path.to.section
ArrayBinding
An array binding with per-element layout information.
Used when an array has comments between elements that need to be preserved.
items = [
// First item
"one",
// Second item
"two",
]Fields
§
path: SourcePathPath to the binding target
§
elements: Vec<ArrayElementLayout>Per-element layout information (comments before each element)
Implementations§
Source§impl LayoutItem
impl LayoutItem
Sourcepub fn line_comment(s: impl Into<String>) -> Self
pub fn line_comment(s: impl Into<String>) -> Self
Create a line comment item.
Sourcepub fn block_comment(s: impl Into<String>) -> Self
pub fn block_comment(s: impl Into<String>) -> Self
Create a block comment item.
Sourcepub fn binding(path: SourcePath, node: NodeId) -> Self
pub fn binding(path: SourcePath, node: NodeId) -> Self
Create a binding item.
Sourcepub fn binding_with_comment(
path: SourcePath,
node: NodeId,
comment: impl Into<String>,
) -> Self
pub fn binding_with_comment( path: SourcePath, node: NodeId, comment: impl Into<String>, ) -> Self
Create a binding item with trailing comment.
Sourcepub fn section(path: SourcePath, items: Vec<LayoutItem>) -> Self
pub fn section(path: SourcePath, items: Vec<LayoutItem>) -> Self
Create a section item with items body.
Sourcepub fn section_block(path: SourcePath, items: Vec<LayoutItem>) -> Self
pub fn section_block(path: SourcePath, items: Vec<LayoutItem>) -> Self
Create a section item with block body.
Sourcepub fn section_with_comment(
path: SourcePath,
comment: impl Into<String>,
items: Vec<LayoutItem>,
) -> Self
pub fn section_with_comment( path: SourcePath, comment: impl Into<String>, items: Vec<LayoutItem>, ) -> Self
Create a section item with trailing comment.
Sourcepub fn array_binding(
path: SourcePath,
node: NodeId,
elements: Vec<ArrayElementLayout>,
) -> Self
pub fn array_binding( path: SourcePath, node: NodeId, elements: Vec<ArrayElementLayout>, ) -> Self
Create an array binding item with per-element layout.
Trait Implementations§
Source§impl Clone for LayoutItem
impl Clone for LayoutItem
Source§fn clone(&self) -> LayoutItem
fn clone(&self) -> LayoutItem
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LayoutItem
impl Debug for LayoutItem
Source§impl PartialEq for LayoutItem
impl PartialEq for LayoutItem
impl StructuralPartialEq for LayoutItem
Auto Trait Implementations§
impl Freeze for LayoutItem
impl RefUnwindSafe for LayoutItem
impl Send for LayoutItem
impl Sync for LayoutItem
impl Unpin for LayoutItem
impl UnwindSafe for LayoutItem
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
Mutably borrows from an owned value. Read more