mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-29 06:44:49 +00:00
More flexible map_user and fold for new constructor nodes (#53)
* make fold.rs file * Split user_map steps * Fold for new constructor nodes
This commit is contained in:
parent
205ee80033
commit
b48834fe2d
6 changed files with 2516 additions and 833 deletions
|
@ -15,8 +15,12 @@ impl ConstantOptimizer {
|
|||
impl<U> crate::fold::Fold<U> for ConstantOptimizer {
|
||||
type TargetU = U;
|
||||
type Error = std::convert::Infallible;
|
||||
type UserContext = ();
|
||||
|
||||
#[inline(always)]
|
||||
fn will_map_user(&mut self, _user: &U) -> Self::UserContext {}
|
||||
#[inline]
|
||||
fn map_user(&mut self, user: U) -> Result<Self::TargetU, Self::Error> {
|
||||
fn map_user(&mut self, user: U, _context: ()) -> Result<Self::TargetU, Self::Error> {
|
||||
Ok(user)
|
||||
}
|
||||
fn fold_expr(&mut self, node: crate::Expr<U>) -> Result<crate::Expr<U>, Self::Error> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue