pub(super) fn indent_anchor(
    element: &SyntaxElement,
    model: &mut FmtModel,
    anchor_set: &PatternSet<&Pattern>,
) -> Option<(SyntaxNode, IndentLevel)> {
    let parent = element.parent()?;
    for node in parent.ancestors() {
        let block = model.block_for(&node.clone().into(), BlockPosition::Before);
        if block.has_newline() {
            return Some((node.clone(), block.indent()));
        }
        if anchor_set.matching(node.clone().into()).next().is_some() {
            let indent = model.indent_of(&node);
            return Some((node, indent));
        }
        // For the root node, the block will typically be empty, but it still
        // should be considered an indent anchor.
        if node.kind() == NODE_ROOT {
            return Some((node, IndentLevel::default()));
        }
    }
    None
}
/// Computes an anchoring element, together with its indent.
///
/// By default, the anchor is an ancestor of `element` which itself is the first
/// element on the line.
///
/// Elements from `anchor_set` are considered anchors even if they don't begin
/// the line.
Computes an anchoring element, together with its indent.
By default, the anchor is an ancestor of `element` which itself is the first
element on the line.

Elements from `anchor_set` are considered anchors even if they don't begin
the line.
Computes an anchoring element together with its indent . By default the anchor is an ancestor of ` element ` which itself is the first element on the line . Elements from ` anchor_set ` are considered anchors even if they don ' t begin the line .
pub(super) fn indent_anchor(
    element: &SyntaxElement,
    model: &mut FmtModel,
    anchor_set: &PatternSet<&Pattern>,
) -> Option<(SyntaxNode, IndentLevel)> {
    let parent = element.parent()?;
    for node in parent.ancestors() {
        let block = model.block_for(&node.clone().into(), BlockPosition::Before);
        if block.has_newline() {
            return Some((node.clone(), block.indent()));
        }
        if anchor_set.matching(node.clone().into()).next().is_some() {
            let indent = model.indent_of(&node);
            return Some((node, indent));
        }
        // For the root node, the block will typically be empty, but it still
        // should be considered an indent anchor.
        if node.kind() == NODE_ROOT {
            return Some((node, IndentLevel::default()));
        }
    }
    None
}
pub ( super ) fn indent_anchor ( element : & SyntaxElement , model : & mut FmtModel , anchor_set : & PatternSet < & Pattern > , ) -> Option < ( SyntaxNode , IndentLevel ) > { let parent = element . parent ( ) ? ; for node in parent . ancestors ( ) { let block = model . block_for ( & node . clone ( ) . into ( ) , BlockPosition :: Before ) ; if block . has_newline ( ) { return Some ( ( node . clone ( ) , block . indent ( ) ) ) ; } if anchor_set . matching ( node . clone ( ) . into ( ) ) . next ( ) . is_some ( ) { let indent = model . indent_of ( & node ) ; return Some ( ( node , indent ) ) ; } // For the root node, the block will typically be empty, but it still // should be considered an indent anchor. if node . kind ( ) == NODE_ROOT { return Some ( ( node , IndentLevel :: default ( ) ) ) ; } } None }
Computes an anchoring element, together with its indent.
Computes an anchoring element together with its indent .
element
&SyntaxElement
model
&mut FmtModel
anchor_set
&PatternSet<&Pattern>