mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-25 02:20:49 +00:00
Move syntax Include to gen Include conversion to From impl
This commit is contained in:
parent
2cc2e3a4d1
commit
353d98cdd9
@ -1,5 +1,5 @@
|
||||
use crate::gen::out::OutFile;
|
||||
use crate::syntax::IncludeKind;
|
||||
use crate::syntax::{self, IncludeKind};
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
/// The complete contents of the "rust/cxx.h" header.
|
||||
@ -84,8 +84,8 @@ impl Includes {
|
||||
Includes::default()
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, include: Include) {
|
||||
self.custom.push(include);
|
||||
pub fn insert(&mut self, include: impl Into<Include>) {
|
||||
self.custom.push(include.into());
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,6 +95,15 @@ impl<'a> Extend<&'a Include> for Includes {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a syntax::Include> for Include {
|
||||
fn from(include: &syntax::Include) -> Self {
|
||||
Include {
|
||||
path: include.path.clone(),
|
||||
kind: include.kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Includes {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for include in &self.custom {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use crate::gen::include::Include;
|
||||
use crate::gen::out::OutFile;
|
||||
use crate::gen::{include, Opt};
|
||||
use crate::syntax::atom::Atom::{self, *};
|
||||
@ -25,9 +24,7 @@ pub(super) fn gen(
|
||||
out.include.extend(&opt.include);
|
||||
for api in apis {
|
||||
if let Api::Include(include) = api {
|
||||
let path = include.path.clone();
|
||||
let kind = include.kind;
|
||||
out.include.insert(Include { path, kind });
|
||||
out.include.insert(include);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user