make fold.rs file

This commit is contained in:
Jeong YunWon 2023-05-17 00:04:27 +09:00
parent 205ee80033
commit 9f834b4be1
3 changed files with 7 additions and 10 deletions

View file

@ -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)

View file

@ -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");

View file

@ -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;