Skip to content

Commit 353d98c

Browse files
committed
Move syntax Include to gen Include conversion to From impl
1 parent 2cc2e3a commit 353d98c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

gen/src/include.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::gen::out::OutFile;
2-
use crate::syntax::IncludeKind;
2+
use crate::syntax::{self, IncludeKind};
33
use std::fmt::{self, Display};
44

55
/// The complete contents of the "rust/cxx.h" header.
@@ -84,8 +84,8 @@ impl Includes {
8484
Includes::default()
8585
}
8686

87-
pub fn insert(&mut self, include: Include) {
88-
self.custom.push(include);
87+
pub fn insert(&mut self, include: impl Into<Include>) {
88+
self.custom.push(include.into());
8989
}
9090
}
9191

@@ -95,6 +95,15 @@ impl<'a> Extend<&'a Include> for Includes {
9595
}
9696
}
9797

98+
impl<'a> From<&'a syntax::Include> for Include {
99+
fn from(include: &syntax::Include) -> Self {
100+
Include {
101+
path: include.path.clone(),
102+
kind: include.kind,
103+
}
104+
}
105+
}
106+
98107
impl Display for Includes {
99108
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100109
for include in &self.custom {

gen/src/write.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::gen::include::Include;
21
use crate::gen::out::OutFile;
32
use crate::gen::{include, Opt};
43
use crate::syntax::atom::Atom::{self, *};
@@ -25,9 +24,7 @@ pub(super) fn gen(
2524
out.include.extend(&opt.include);
2625
for api in apis {
2726
if let Api::Include(include) = api {
28-
let path = include.path.clone();
29-
let kind = include.kind;
30-
out.include.insert(Include { path, kind });
27+
out.include.insert(include);
3128
}
3229
}
3330

0 commit comments

Comments
 (0)