mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-22 00:54:33 +00:00
Inline Pair construction
This commit is contained in:
parent
885be13744
commit
c2a4c78a13
@ -131,7 +131,11 @@ mod tests {
|
||||
doc: Doc::new(),
|
||||
derives: Vec::new(),
|
||||
type_token: Token),
|
||||
name: Pair::new(ns, ident.clone(), ident),
|
||||
name: Pair {
|
||||
namespace: ns,
|
||||
cxx: ident.clone(),
|
||||
rust: ident,
|
||||
},
|
||||
colon_token: None,
|
||||
bounds: Vec::new(),
|
||||
semi_token: Token),
|
||||
|
@ -1,16 +1,8 @@
|
||||
use crate::syntax::{Namespace, Pair, RustName, Symbol, Types};
|
||||
use crate::syntax::{Pair, RustName, Symbol, Types};
|
||||
use proc_macro2::{Ident, Span};
|
||||
use std::iter;
|
||||
|
||||
impl Pair {
|
||||
pub fn new(namespace: Namespace, cxx: Ident, rust: Ident) -> Self {
|
||||
Pair {
|
||||
namespace,
|
||||
cxx,
|
||||
rust,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_symbol(&self) -> Symbol {
|
||||
Symbol::from_idents(self.iter_all_segments())
|
||||
}
|
||||
|
@ -1047,9 +1047,9 @@ fn parse_return_type(
|
||||
|
||||
fn pair(namespace: Namespace, default: &Ident, cxx: Option<Ident>, rust: Option<Ident>) -> Pair {
|
||||
let default = || default.clone();
|
||||
Pair::new(
|
||||
Pair {
|
||||
namespace,
|
||||
cxx.unwrap_or_else(default),
|
||||
rust.unwrap_or_else(default),
|
||||
)
|
||||
cxx: cxx.unwrap_or_else(default),
|
||||
rust: rust.unwrap_or_else(default),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user