mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-08 05:35:22 +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):
|
||||
def visitModule(self, mod):
|
||||
depth = 0
|
||||
self.emit("use crate::fold_helpers::Foldable;", depth)
|
||||
FoldTraitDefVisitor(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> {
|
||||
type Mapped;
|
||||
|
@ -49,7 +51,7 @@ where
|
|||
|
||||
macro_rules! simple_fold {
|
||||
($($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;
|
||||
#[inline]
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
|
@ -70,3 +72,5 @@ simple_fold!(
|
|||
ConversionFlag,
|
||||
builtin::Constant
|
||||
);
|
||||
|
||||
include!("gen/fold.rs");
|
|
@ -16,13 +16,7 @@ pub trait Node {
|
|||
}
|
||||
|
||||
#[cfg(feature = "fold")]
|
||||
mod fold_helpers;
|
||||
#[cfg(feature = "fold")]
|
||||
pub mod fold {
|
||||
use super::generic::*;
|
||||
|
||||
include!("gen/fold.rs");
|
||||
}
|
||||
pub mod fold;
|
||||
#[cfg(feature = "fold")]
|
||||
pub use fold::Fold;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue