Skip to content

Commit fbc8150

Browse files
bors[bot]bossmc
andauthored
Merge #97
97: Make context macros self-contained r=bossmc a=bossmc With this, the various `make_context_X` macros never reference names from the local crate without fully qualifying them. Without this, users of the macros would have to `use` various swagger traits/macros (or `#[macro_use]` the crate). Co-authored-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
2 parents e6a653e + 71b99eb commit fbc8150

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/context.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ pub trait Push<T> {
177177
///
178178
/// E.g.
179179
///
180-
/// ```rust
181-
/// # #[macro_use] extern crate swagger;
182-
/// # use swagger::{Has, Pop, Push};
183-
///
180+
/// ```rust2018
184181
/// #[derive(Default)]
185182
/// struct MyType1;
186183
/// #[derive(Default)]
@@ -197,7 +194,7 @@ pub trait Push<T> {
197194
/// fn use_has_my_type_3<T: Has<MyType3>> (_: &T) {}
198195
/// fn use_has_my_type_4<T: Has<MyType4>> (_: &T) {}
199196
///
200-
/// // will implement `Has<MyType1>` and `Has<MyType2>` because these appear
197+
/// // Will implement `Has<MyType1>` and `Has<MyType2>` because these appear
201198
/// // in the type, and were passed to `new_context_type!`. Will not implement
202199
/// // `Has<MyType3>` even though it was passed to `new_context_type!`, because
203200
/// // it is not included in the type.
@@ -246,7 +243,7 @@ macro_rules! new_context_type {
246243
// implement `Push<T>` on the empty context type for each type `T` that
247244
// was passed to the macro
248245
$(
249-
impl Push<$types> for $empty_context_name {
246+
impl $crate::Push<$types> for $empty_context_name {
250247
type Result = $context_name<$types, Self>;
251248
fn push(self, item: $types) -> Self::Result {
252249
$context_name{head: item, tail: Self::default()}
@@ -278,7 +275,7 @@ macro_rules! new_context_type {
278275

279276
// implement `Push<U>` for non-empty lists, for each type `U` that was passed
280277
// to the macro
281-
impl<C, T> Push<$types> for $context_name<T, C> {
278+
impl<C, T> $crate::Push<$types> for $context_name<T, C> {
282279
type Result = $context_name<$types, Self>;
283280
fn push(self, item: $types) -> Self::Result {
284281
$context_name{head: item, tail: self}
@@ -288,7 +285,7 @@ macro_rules! new_context_type {
288285

289286
// Add implementations of `Has<T>` and `Pop<T>` when `T` is any type stored in
290287
// the list, not just the head.
291-
new_context_type!(impl extend_has $context_name, $empty_context_name, $($types),+);
288+
$crate::new_context_type!(impl extend_has $context_name, $empty_context_name, $($types),+);
292289
};
293290

294291
// "HELPER" MACRO CASE - NOT FOR EXTERNAL USE
@@ -311,7 +308,7 @@ macro_rules! new_context_type {
311308
$head,
312309
$($tail),+
313310
);
314-
new_context_type!(impl extend_has $context_name, $empty_context_name, $($tail),+);
311+
$crate::new_context_type!(impl extend_has $context_name, $empty_context_name, $($tail),+);
315312
};
316313

317314
// "HELPER" MACRO CASE - NOT FOR EXTERNAL USE

0 commit comments

Comments
 (0)