Is this code good enough or Cloned can be removed somehow

use std::ops::Range;
use std::rc::Rc;

#[derive(Debug, Clone)]
pub struct SyntaxNode {
    kind: SyntaxKind,
    span: Range<usize>,
    text: Rc<str>,
    children: Vec<SyntaxNode>,
}

impl SyntaxNode {
    pub fn children(&self) -> impl Iterator<Item=SyntaxNode> {
        self.children.iter().cloned() // <----- Can this cloned be removed
    }

    pub fn kind(&self) -> SyntaxKind {
        self.kind
    }
}

pub trait AstNode: Sized {
    fn can_cast(kind: SyntaxKind) -> bool;

    fn cast(syntax: SyntaxNode) -> Option<Self>;

    fn syntax(&self) -> &SyntaxNode;

    fn children(&self) -> impl Iterator<Item = SyntaxNode> {
        self.syntax().children()
    }
}

struct Grammar {
    syntax: SyntaxNode,
}

impl AstNode for Grammar {
    fn can_cast(kind: SyntaxKind) -> bool {
        kind == GRAMMAR
    }

    fn cast(syntax: SyntaxNode) -> Option<Self> {
        if Self::can_cast(syntax.kind()) {
            Some(Self {
                syntax
            })
        } else {
            None
        }
    }

    fn syntax(&self) -> &SyntaxNode {
        &self.syntax
    }
}

struct Rule {
    syntax: SyntaxNode,
}

impl AstNode for Rule {
    fn can_cast(kind: SyntaxKind) -> bool {
        kind == RULE
    }

    fn cast(syntax: SyntaxNode) -> Option<Self> {
        if Self::can_cast(syntax.kind()) {
            Some(Self {
                syntax
            })
        } else {
            None
        }
    }

    fn syntax(&self) -> &SyntaxNode {
        &self.syntax
    }
}

impl Grammar {
    fn rules(&self) -> impl Iterator<Item = Rule> {
        self.children()
            .filter_map(Rule::cast)
    }
}

is this code good enough or Cloned can be removed somehow?

There sure is!

    pub fn children(&self) -> impl Iterator<Item = &SyntaxNode> {
        self.children.iter()
    }

Note that the call sites will need to be updated as well. In particular, since Rule owns the underlying SyntaxNode, I fear there is no avoiding at least some cloning (not without changing Rule anyways).

thanks