fn next_space_for_fn_after_call_site(expr: FuncExpr) -> Option<GeneratedFunctionTarget> {
    let mut ancestors = expr.syntax().ancestors().peekable();
    let mut last_ancestor: Option<SyntaxNode> = None;
    while let Some(next_ancestor) = ancestors.next() {
        match next_ancestor.kind() {
            SyntaxKind::SOURCE_FILE => {
                break;
            }
            SyntaxKind::ITEM_LIST => {
                if ancestors.peek().map(|a| a.kind()) == Some(SyntaxKind::MODULE) {
                    break;
                }
            }
            _ => {}
        }
        last_ancestor = Some(next_ancestor);
    }
    last_ancestor.map(GeneratedFunctionTarget::BehindItem)
}
/// Returns the position inside the current mod or file
/// directly after the current block
/// We want to write the generated function directly after
/// fns, impls or macro calls, but inside mods
Returns the position inside the current mod or file
directly after the current block
We want to write the generated function directly after
fns, impls or macro calls, but inside mods
Returns the position inside the current mod or file directly after the current block We want to write the generated function directly after fns impls or macro calls but inside mods
fn next_space_for_fn_after_call_site(expr: FuncExpr) -> Option<GeneratedFunctionTarget> {
    let mut ancestors = expr.syntax().ancestors().peekable();
    let mut last_ancestor: Option<SyntaxNode> = None;
    while let Some(next_ancestor) = ancestors.next() {
        match next_ancestor.kind() {
            SyntaxKind::SOURCE_FILE => {
                break;
            }
            SyntaxKind::ITEM_LIST => {
                if ancestors.peek().map(|a| a.kind()) == Some(SyntaxKind::MODULE) {
                    break;
                }
            }
            _ => {}
        }
        last_ancestor = Some(next_ancestor);
    }
    last_ancestor.map(GeneratedFunctionTarget::BehindItem)
}
fn next_space_for_fn_after_call_site ( expr : FuncExpr ) -> Option < GeneratedFunctionTarget > { let mut ancestors = expr . syntax ( ) . ancestors ( ) . peekable ( ) ; let mut last_ancestor : Option < SyntaxNode > = None ; while let Some ( next_ancestor ) = ancestors . next ( ) { match next_ancestor . kind ( ) { SyntaxKind :: SOURCE_FILE => { break ; } SyntaxKind :: ITEM_LIST => { if ancestors . peek ( ) . map ( | a | a . kind ( ) ) == Some ( SyntaxKind :: MODULE ) { break ; } } _ => { } } last_ancestor = Some ( next_ancestor ) ; } last_ancestor . map ( GeneratedFunctionTarget :: BehindItem ) }
Returns the position inside the current mod or file
directly after the current block
We want to write the generated function directly after
fns, impls or macro calls, but inside mods
Returns the position inside the current mod or file directly after the current block We want to write the generated function directly after fns impls or macro calls but inside mods
expr
FuncExpr