mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-12 07:35:16 +00:00
make fold.rs file
This commit is contained in:
parent
205ee80033
commit
9f834b4be1
3 changed files with 7 additions and 10 deletions
|
@ -644,7 +644,6 @@ class FoldImplVisitor(EmitVisitor):
|
||||||
class FoldModuleVisitor(EmitVisitor):
|
class FoldModuleVisitor(EmitVisitor):
|
||||||
def visitModule(self, mod):
|
def visitModule(self, mod):
|
||||||
depth = 0
|
depth = 0
|
||||||
self.emit("use crate::fold_helpers::Foldable;", depth)
|
|
||||||
FoldTraitDefVisitor(self.file, self.type_info).visit(mod, depth)
|
FoldTraitDefVisitor(self.file, self.type_info).visit(mod, depth)
|
||||||
FoldImplVisitor(self.file, self.type_info).visit(mod, depth)
|
FoldImplVisitor(self.file, self.type_info).visit(mod, depth)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use crate::{builtin, fold::Fold, ConversionFlag};
|
use super::generic::*;
|
||||||
|
|
||||||
|
use crate::{builtin, ConversionFlag};
|
||||||
|
|
||||||
pub trait Foldable<T, U> {
|
pub trait Foldable<T, U> {
|
||||||
type Mapped;
|
type Mapped;
|
||||||
|
@ -49,7 +51,7 @@ where
|
||||||
|
|
||||||
macro_rules! simple_fold {
|
macro_rules! simple_fold {
|
||||||
($($t:ty),+$(,)?) => {
|
($($t:ty),+$(,)?) => {
|
||||||
$(impl<T, U> $crate::fold_helpers::Foldable<T, U> for $t {
|
$(impl<T, U> $crate::fold::Foldable<T, U> for $t {
|
||||||
type Mapped = Self;
|
type Mapped = Self;
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||||
|
@ -70,3 +72,5 @@ simple_fold!(
|
||||||
ConversionFlag,
|
ConversionFlag,
|
||||||
builtin::Constant
|
builtin::Constant
|
||||||
);
|
);
|
||||||
|
|
||||||
|
include!("gen/fold.rs");
|
|
@ -16,13 +16,7 @@ pub trait Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "fold")]
|
#[cfg(feature = "fold")]
|
||||||
mod fold_helpers;
|
pub mod fold;
|
||||||
#[cfg(feature = "fold")]
|
|
||||||
pub mod fold {
|
|
||||||
use super::generic::*;
|
|
||||||
|
|
||||||
include!("gen/fold.rs");
|
|
||||||
}
|
|
||||||
#[cfg(feature = "fold")]
|
#[cfg(feature = "fold")]
|
||||||
pub use fold::Fold;
|
pub use fold::Fold;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue