Is there a way to cast a fn(&mut Parser) -> Box<Identifier> to a fn(&mut Parser) -> Box<dyn Expression>, or a better way to achieve this? I don't want to make the parse_identifier return a Box<dyn Expression> to avoid casting afterward (after initialisation)
Do you need parse_identifier to return the concrete type? Otherwise, you can easily coerce it right there by having it return Box<dyn Expression -- your Box::new will automatically be unsized. (nevermind, you answered that...)
Otherwise, you'll have to wrap the function to "cast" it, in order to create that conversion from a thin Box<Identifier> to a fat pointer Box<dyn Expression>. A closure will do fine: