let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "clone", "Clone")),
+ path: path!(std::clone::Clone),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: vec!(borrowed_self()),
- ret_ty: Literal(Path::new(vec!("bool"))),
+ ret_ty: Literal(path!(bool)),
attributes: attrs,
combine_substructure: combine_substructure(box |a, b, c| {
$f(a, b, c)
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "cmp", "PartialEq")),
+ path: path!(std::cmp::PartialEq),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: vec!(borrowed_self()),
- ret_ty: Literal(Path::new(vec!("bool"))),
+ ret_ty: Literal(path!(bool)),
attributes: attrs,
combine_substructure: combine_substructure(box |cx, span, substr| {
cs_op($op, $equal, cx, span, substr)
} }
}
- let ordering_ty = Literal(Path::new(vec!["std", "cmp", "Ordering"]));
- let ret_ty = Literal(Path::new_(vec!["std", "option", "Option"],
+ let ordering_ty = Literal(path!(std::cmp::Ordering));
+ let ret_ty = Literal(Path::new_(pathvec!(std::option::Option),
None,
vec![box ordering_ty],
true));
let trait_def = TraitDef {
span: span,
attributes: vec![],
- path: Path::new(vec!["std", "cmp", "PartialOrd"]),
+ path: path!(std::cmp::PartialOrd),
additional_bounds: vec![],
generics: LifetimeBounds::empty(),
methods: vec![
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "cmp", "Eq")),
+ path: path!(std::cmp::Eq),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "cmp", "Ord")),
+ path: path!(std::cmp::Ord),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: vec!(borrowed_self()),
- ret_ty: Literal(Path::new(vec!("std", "cmp", "Ordering"))),
+ ret_ty: Literal(path!(std::cmp::Ordering)),
attributes: attrs,
combine_substructure: combine_substructure(box |a, b, c| {
cs_cmp(a, b, c)
args: vec!(Ptr(box Literal(Path::new_local("__D")),
Borrowed(None, MutMutable))),
ret_ty: Literal(Path::new_(
- vec!("std", "result", "Result"),
+ pathvec!(std::result::Result),
None,
vec!(box Self, box Literal(Path::new_(
vec!["__D", "Error"], None, vec![], false
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "default", "Default")),
+ path: path!(std::default::Default),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
args: vec!(Ptr(box Literal(Path::new_local("__S")),
Borrowed(None, MutMutable))),
ret_ty: Literal(Path::new_(
- vec!("std", "result", "Result"),
+ pathvec!(std::result::Result),
None,
vec!(box Tuple(Vec::new()), box Literal(Path::new_(
vec!["__S", "Error"], None, vec![], false
F: FnOnce(P<Item>),
{
- let path = Path::new_(vec!("std", "hash", "Hash"), None,
+ let path = Path::new_(pathvec!(std::hash::Hash), None,
vec!(box Literal(Path::new_local("__S"))), true);
let generics = LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("__S",
- vec!(Path::new(vec!("std", "hash", "Writer")),
- Path::new(vec!("std", "hash", "Hasher"))))),
+ vec!(path!(std::hash::Writer),
+ path!(std::hash::Hasher)))),
};
let args = Path::new_local("__S");
let inline = cx.meta_word(span, InternedString::new("inline"));
use codemap::Span;
use ptr::P;
+macro_rules! pathvec {
+ ($($x:ident)::+) => (
+ vec![ $( stringify!($x) ),+ ]
+ )
+}
+
+macro_rules! path {
+ ($($x:tt)*) => (
+ ::ext::deriving::generic::ty::Path::new( pathvec!( $($x)* ) )
+ )
+}
+
pub mod bounds;
pub mod clone;
pub mod encodable;
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "num", "FromPrimitive")),
+ path: path!(std::num::FromPrimitive),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
name: "from_i64",
generics: LifetimeBounds::empty(),
explicit_self: None,
- args: vec!(
- Literal(Path::new(vec!("i64")))),
- ret_ty: Literal(Path::new_(vec!("std", "option", "Option"),
+ args: vec!(Literal(path!(i64))),
+ ret_ty: Literal(Path::new_(pathvec!(std::option::Option),
None,
vec!(box Self),
true)),
name: "from_u64",
generics: LifetimeBounds::empty(),
explicit_self: None,
- args: vec!(
- Literal(Path::new(vec!("u64")))),
- ret_ty: Literal(Path::new_(vec!("std", "option", "Option"),
+ args: vec!(Literal(path!(u64))),
+ ret_ty: Literal(Path::new_(pathvec!(std::option::Option),
None,
vec!(box Self),
true)),
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!("std", "rand", "Rand")),
+ path: path!(std::rand::Rand),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec!(
generics: LifetimeBounds {
lifetimes: Vec::new(),
bounds: vec!(("R",
- vec!( Path::new(vec!("std", "rand", "Rng")) )))
+ vec!( path!(std::rand::Rng) ))),
},
explicit_self: None,
args: vec!(
F: FnOnce(P<Item>),
{
// &mut ::std::fmt::Formatter
- let fmtr = Ptr(box Literal(Path::new(vec!("std", "fmt", "Formatter"))),
+ let fmtr = Ptr(box Literal(path!(std::fmt::Formatter)),
Borrowed(None, ast::MutMutable));
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
- path: Path::new(vec!["std", "fmt", "Debug"]),
+ path: path!(std::fmt::Debug),
additional_bounds: Vec::new(),
generics: LifetimeBounds::empty(),
methods: vec![
generics: LifetimeBounds::empty(),
explicit_self: borrowed_explicit_self(),
args: vec!(fmtr),
- ret_ty: Literal(Path::new(vec!("std", "fmt", "Result"))),
+ ret_ty: Literal(path!(std::fmt::Result)),
attributes: Vec::new(),
combine_substructure: combine_substructure(box |a, b, c| {
show_substructure(a, b, c)