Skip to content

Commit

Permalink
feat: more
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Jun 4, 2024
1 parent c77cc4a commit c2fa1c0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion frb_codegen/src/library/codegen/generator/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ impl PathText {
pub(crate) fn new(path: PathBuf, text: String) -> Self {
Self { path, text }
}

pub(crate) fn merge(&self, other: &Self) -> Self {
assert_eq!(self.path, other.path);
Self {
path: self.path.clone(),
text: self.text.clone() + other.text,
}
}
}

#[derive(Clone)]
Expand All @@ -59,7 +67,15 @@ impl Add for PathTexts {
type Output = Self;

fn add(self, rhs: Self) -> Self::Output {
Self([self.0, rhs.0].concat())
Self(
[self.0, rhs.0]
.concat()
.into_iter()
.into_group_map_by(|x| x.path.clone())
.into_iter()
.map(|(_, v)| v.into_iter().reduce(|a, b| a.merge(b)).unwrap())
.collect_vec(),
)
}
}

Expand Down

0 comments on commit c2fa1c0

Please sign in to comment.