Skip to content

Commit

Permalink
Combine Generics impl blocks into one
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 11, 2024
1 parent a482734 commit 64b0dc8
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,34 +248,7 @@ impl Generics {
predicates: Punctuated::new(),
})
}
}

/// Returned by `Generics::split_for_impl`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct ImplGenerics<'a>(&'a Generics);

/// Returned by `Generics::split_for_impl`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct TypeGenerics<'a>(&'a Generics);

/// Returned by `TypeGenerics::as_turbofish`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct Turbofish<'a>(&'a Generics);

#[cfg(feature = "printing")]
impl Generics {
/// Split a type's generics into the pieces required for impl'ing a trait
/// for that type.
///
Expand All @@ -294,6 +267,7 @@ impl Generics {
/// }
/// # ;
/// ```
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
Expand All @@ -307,6 +281,30 @@ impl Generics {
}
}

/// Returned by `Generics::split_for_impl`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct ImplGenerics<'a>(&'a Generics);

/// Returned by `Generics::split_for_impl`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct TypeGenerics<'a>(&'a Generics);

/// Returned by `TypeGenerics::as_turbofish`.
#[cfg(feature = "printing")]
#[cfg_attr(
docsrs,
doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing")))
)]
pub struct Turbofish<'a>(&'a Generics);

#[cfg(feature = "printing")]
macro_rules! generics_wrapper_impls {
($ty:ident) => {
Expand Down

0 comments on commit 64b0dc8

Please sign in to comment.